diff --git a/ui/src/checklist.test.tsx b/ui/src/checklist.test.tsx
index 8eb82a1528..b957644ade 100644
--- a/ui/src/checklist.test.tsx
+++ b/ui/src/checklist.test.tsx
@@ -70,13 +70,13 @@ describe('Checklist.tsx', () => {
const { getByText, rerender } = render()
expect(wave.args[name]).toMatchObject(['Choice1'])
- rerender()
+ rerender()
expect(wave.args[name]).toMatchObject([])
fireEvent.click(getByText('Choice2').parentElement!)
expect(wave.args[name]).toMatchObject(['Choice2'])
- rerender()
+ rerender()
expect(wave.args[name]).toMatchObject([])
})
diff --git a/ui/src/checklist.tsx b/ui/src/checklist.tsx
index 52c9babb0f..b16990b90f 100644
--- a/ui/src/checklist.tsx
+++ b/ui/src/checklist.tsx
@@ -83,13 +83,17 @@ export const
const _choices = choices.map(({ c, selected }) => ({ c, selected: c.disabled ? selected : value }))
setChoices(_choices)
capture(_choices)
+ m.values = value ? _choices.map(({ c }) => c.name) : []
},
selectAll = () => select(true),
deselectAll = () => select(false),
onChange = (idx: U) => (_e?: React.FormEvent, checked = false) => {
const _choices = [...choices]
- _choices[idx].selected = checked
+ const choice = _choices[idx]
+ choice.selected = checked
setChoices(_choices)
+ checked ? defaultSelection.add(choice.c.name) : defaultSelection.delete(choice.c.name)
+ m.values = [...defaultSelection]
capture(_choices)
},
items = choices.map(({ c, selected }, i) => (