-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combobox selects the active value when the focus is moved away #2934
Comments
For what it's worth, I think the two cases in combobox.tsx where the code tests for |
Got the same issue unjs/website#285 Clearly a regression from the previous version. |
Hey! So the "tab to select" behavior is intended for this component. This is consistent with how other combobox libraries work, like React Aria Components, as well as with the native If you're using the new I have tested this on the latest insiders version of both the React and Vue libraries. Here's a video demonstrating this behavior (with the Screen.Recording.2024-02-07.at.5.01.14.PM.movGoing to close this one for now, since this all feels like expected behavior to me. However, if for some strange reason this isn't what you're experiencing, please provide a minimal reproduction and maybe even a video showing the issue and we can take another look 👍 |
Just throwing my two cents here, mainly on a click navigation: Isn't the concept of "clicking away, without explicitely selecting something" be considered as "cancel the operation"? With the current implementation it seems to me that there is no way to cancel the operation using only mouse navigation |
@sandros94 I agree 100%. Which is the reason I'm using the patch I outlined in the 2nd post of this issue. @reinink In addition to the point above, I was seeing a worse behaviour, because I'm loading the list of suggestions on the fly when the user focuses the field. What happened was:
Would it be possible to have my patch above as a toggle prop? Would you accept a pull requests that adds the prop? |
this behavior is reasonable in some cases but unreasonable in others, so please give us an option to deactivate it. Clicking away should be aborting the selection. |
@sandros94 @tobia @Fabioni Hey! So just looking at this issue again I am realizing that I never mentioned the You can read more about this in my comment here: #2932 (comment) I think this will solve the issue for you. Right now, by default, the We're actually considering making this the default behavior in Headless UI v2, although that's not a guarantee yet. Hope that helps! 🙏 |
Hey folks! Just wanted to let you know that the upcoming v2 release is going to make the combobox "nullable by default". You can read more about this change in #3064. Thanks for sharing all this feedback! 👍 |
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
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.
The text was updated successfully, but these errors were encountered: