diff --git a/code/system.ui/react.common/src/ui/LabelItem.Model/List.commands.ts b/code/system.ui/react.common/src/ui/LabelItem.Model/List.commands.ts index 95d0c282bf..1ebbb569b8 100644 --- a/code/system.ui/react.common/src/ui/LabelItem.Model/List.commands.ts +++ b/code/system.ui/react.common/src/ui/LabelItem.Model/List.commands.ts @@ -16,6 +16,7 @@ export function commands(list?: t.LabelListState) { return api; }, remove(index) { + if (index === undefined || index < 0) return api; dispatch({ type: 'List:Remove', payload: { index, tx: slug() } }); return api; }, diff --git a/code/system.ui/react.common/src/ui/LabelItem.Model/List.t.ts b/code/system.ui/react.common/src/ui/LabelItem.Model/List.t.ts index 3e9568ac69..18d80af488 100644 --- a/code/system.ui/react.common/src/ui/LabelItem.Model/List.t.ts +++ b/code/system.ui/react.common/src/ui/LabelItem.Model/List.t.ts @@ -44,7 +44,7 @@ export type LabelListEvents = t.Lifecycle & { export type LabelListDispatch = { select(item: Index | Id, focus?: boolean): LabelListDispatch; redraw(item?: Index | Id): LabelListDispatch; - remove(index: Index): LabelListDispatch; + remove(index?: Index): LabelListDispatch; focus(focus?: boolean): LabelListDispatch; blur(): LabelListDispatch; }; diff --git a/code/system.ui/react.common/src/ui/LabelItem.Stateful/-dev/-SPEC.tsx b/code/system.ui/react.common/src/ui/LabelItem.Stateful/-dev/-SPEC.tsx index 3a1dea3a90..c7f507aa14 100644 --- a/code/system.ui/react.common/src/ui/LabelItem.Stateful/-dev/-SPEC.tsx +++ b/code/system.ui/react.common/src/ui/LabelItem.Stateful/-dev/-SPEC.tsx @@ -37,7 +37,8 @@ export default Dev.describe(name, (e) => { init: { list(dev: t.DevCtxState) { const list = TestState.list; - list.events().cmd.remove$.subscribe((e) => { + const events = list.events(); + events.cmd.remove$.subscribe((e) => { local.total = TestState.array.remove(e.index).length; }); },