Skip to content

Commit 1e6c815

Browse files
committed
add test to ensure <Combobox nullable /> doesn't crash
1 parent 90c09fe commit 1e6c815

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/@headlessui-react/src/components/combobox/combobox.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,31 @@ describe('Rendering', () => {
575575
assertComboboxList({ state: ComboboxState.InvisibleUnmounted })
576576
})
577577
)
578+
579+
it(
580+
'should not crash when the `Combobox` still contains a `nullable` prop',
581+
suppressConsoleLogs(async () => {
582+
let data = [
583+
{ id: 1, name: 'alice', label: 'Alice' },
584+
{ id: 2, name: 'bob', label: 'Bob' },
585+
{ id: 3, name: 'charlie', label: 'Charlie' },
586+
]
587+
588+
render(
589+
<Combobox nullable>
590+
<Combobox.Input onChange={NOOP} />
591+
<Combobox.Button />
592+
<Combobox.Options>
593+
{data.map((person) => (
594+
<Combobox.Option key={person.id} value={person}>
595+
{person.label}
596+
</Combobox.Option>
597+
))}
598+
</Combobox.Options>
599+
</Combobox>
600+
)
601+
})
602+
)
578603
})
579604

580605
describe('Combobox.Input', () => {

0 commit comments

Comments
 (0)