Combo box can't add space in input #1687
-
What package within Headless UI are you using? @headlessui/react What version of that package are you using? v1.6.6 What browser are you using? Chrome, Firefox Reproduction URL Describe your issue When I try to type Just go to repo URL and try to type |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey! This is because you've wrapped your <Combobox value={selectedPerson} onChange={setSelectedPerson}>
<Combobox.Input onChange={(event) => setQuery(event.target.value)} />
<Combobox.Options>
{filteredPeople.map((person) => (
<Combobox.Option key={person} value={person}>
{person}
</Combobox.Option>
))}
</Combobox.Options>
</Combobox> The |
Beta Was this translation helpful? Give feedback.
-
If you are using headless ui version 2, add <ComboboxInput
onKeyDown={e => e.stopPropagation()}
/> |
Beta Was this translation helpful? Give feedback.
Hey! This is because you've wrapped your
Combobox.Input
in aCombobox.Button
and the space key is propagating up to the button and triggering a click. Don't put the input in the button, the input should be on it's own like in our docs:The
Combobox.Button
component is an optional component you can use to manually open/close t…