diff --git a/ui/src/combobox.test.tsx b/ui/src/combobox.test.tsx
index 0e7fc8e135..b2c6ad5893 100644
--- a/ui/src/combobox.test.tsx
+++ b/ui/src/combobox.test.tsx
@@ -46,7 +46,7 @@ describe('Combobox.tsx', () => {
})
it('Sets args - multiple selection', () => {
- const { getByRole, getByText } = render()
+ const { getByRole, getByText } = render()
fireEvent.click(getByRole('presentation', { hidden: true }))
fireEvent.click(getByText('Choice1'))
fireEvent.click(getByText('Choice2'))
@@ -86,4 +86,13 @@ describe('Combobox.tsx', () => {
expect(pushMock).toHaveBeenCalled()
})
+
+ it('Selects and unselects a user typed option', () => {
+ const { getByRole, getByText } = render()
+ userEvent.type(getByRole('combobox'), 'Choice4{Enter}')
+ expect(wave.args[name]).toEqual(['Choice4'])
+ fireEvent.click(getByRole('presentation', { hidden: true }))
+ fireEvent.click(getByText('Choice4'))
+ expect(wave.args[name]).toEqual([])
+ })
})
\ No newline at end of file
diff --git a/ui/src/combobox.tsx b/ui/src/combobox.tsx
index 36a61615d4..0c4b905e4c 100644
--- a/ui/src/combobox.tsx
+++ b/ui/src/combobox.tsx
@@ -75,9 +75,9 @@ export const
},
onChange = (_e: React.FormEvent, option?: Fluent.IComboBoxOption, _index?: U, value?: S) => {
if (!option && value) {
- const opt: Fluent.IComboBoxOption = { key: value, text: value, selected: true }
+ const opt: Fluent.IComboBoxOption = { key: value, text: value }
setOptions((prevOptions = []) => [...prevOptions, opt])
- selectOpt(opt)
+ selectOpt({...opt, selected: true})
}
if (option && isMultiValued) {
selectOpt(option)