-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
Both 1.7.18 and 0.0.0-insiders.3b961a6
What browser are you using?
Firefox, Chrome
Reproduction URL
This can be easily reproduced on the demo page: https://headlessui.com/react/combobox
Describe your issue
- Open the demo page https://headlessui.com/react/combobox
- Click on the double-arrow button to open the list.
- Use the keyboard to navigate the list, for instance hitting Down a couple times: this will change the active item, but not the selected item.
- Do *not select the item with either Enter or Click, instead use Tab to move out of the field.
Expected behaviour: the field's selected value should remain unchanged.
Actual behaviour: the item that was active in the menu gets selected as the field value.
This is particularly problematic with the new immediate option available in the insiders release, because now you can alter the field values just by Tabbing through a form.
This is because as soon as the focus enters a Combobox in immediate mode, the menu of options is made visible and the first item is automatically made active, then hitting Tab again selects the active item, thus changing the value of the field.
Proposed solution: the active item should become selected only when a specific set of events occur, namely mouse Click or Enter key.