-
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.input value gets out of sync with search term state #1875
Comments
Just fyi, I updated to 1.7.3 and this issue exists there too |
Hey, thanks for reporting this! This should be fixed by #1916, and will be available in the next release. You can already try it using (may take a few minutes to publish to npm):
|
@thecrypticace still running into this via |
…or externally I also got rid of the manually dispatching of the change event if the value changes from internally. I think the correct mental model is: - That the `Combobox.Input` value should change if the selected value changes from the outside or from the inside. - Note: It should _not_ do that if you are currently typing (once you choose a new value it will re-sync, once you reset (escape / outside click) it will also sync again). - The `onChange`/`onInput` of the `Combobox.Input` itself should only be called if you as the user type something. Not when the value is "synced" based on the selected value. We were currently manually dispatching events which works (to a certain extend) but smelled a bit fishy to me. The manual dispatching of events tried to solve an issue (#1875), but I think this can be solved in 2 other ways that make a bit more sense: 1. (Today) Use the `onBlur` on the input to reset the `query` value to filter options. 2. (In the future) Use an exposed `onClose` (or similar) event to reset your `query` value.
* make combobox playgrounds in React and Vue similar * syncing of the input should happen when the value changes internally or externally I also got rid of the manually dispatching of the change event if the value changes from internally. I think the correct mental model is: - That the `Combobox.Input` value should change if the selected value changes from the outside or from the inside. - Note: It should _not_ do that if you are currently typing (once you choose a new value it will re-sync, once you reset (escape / outside click) it will also sync again). - The `onChange`/`onInput` of the `Combobox.Input` itself should only be called if you as the user type something. Not when the value is "synced" based on the selected value. We were currently manually dispatching events which works (to a certain extend) but smelled a bit fishy to me. The manual dispatching of events tried to solve an issue (#1875), but I think this can be solved in 2 other ways that make a bit more sense: 1. (Today) Use the `onBlur` on the input to reset the `query` value to filter options. 2. (In the future) Use an exposed `onClose` (or similar) event to reset your `query` value. * update changelog * ignore flakey test
* make combobox playgrounds in React and Vue similar * syncing of the input should happen when the value changes internally or externally I also got rid of the manually dispatching of the change event if the value changes from internally. I think the correct mental model is: - That the `Combobox.Input` value should change if the selected value changes from the outside or from the inside. - Note: It should _not_ do that if you are currently typing (once you choose a new value it will re-sync, once you reset (escape / outside click) it will also sync again). - The `onChange`/`onInput` of the `Combobox.Input` itself should only be called if you as the user type something. Not when the value is "synced" based on the selected value. We were currently manually dispatching events which works (to a certain extend) but smelled a bit fishy to me. The manual dispatching of events tried to solve an issue (tailwindlabs/headlessui#1875), but I think this can be solved in 2 other ways that make a bit more sense: 1. (Today) Use the `onBlur` on the input to reset the `query` value to filter options. 2. (In the future) Use an exposed `onClose` (or similar) event to reset your `query` value. * update changelog * ignore flakey test
We wanted to include Combobox component into our app, but ran into the same issue on version 1.7.16 of @headlessui/vue. I saw the comment for the last commit linked to this issue with the suggestion of "Use the Unfortunately, this does not look feasible. We're using
So I was wondering if there are any plans for fixing and/or improving this particular behaviour in the forseeable future? |
* make combobox playgrounds in React and Vue similar * syncing of the input should happen when the value changes internally or externally I also got rid of the manually dispatching of the change event if the value changes from internally. I think the correct mental model is: - That the `Combobox.Input` value should change if the selected value changes from the outside or from the inside. - Note: It should _not_ do that if you are currently typing (once you choose a new value it will re-sync, once you reset (escape / outside click) it will also sync again). - The `onChange`/`onInput` of the `Combobox.Input` itself should only be called if you as the user type something. Not when the value is "synced" based on the selected value. We were currently manually dispatching events which works (to a certain extend) but smelled a bit fishy to me. The manual dispatching of events tried to solve an issue (tailwindlabs/headlessui#1875), but I think this can be solved in 2 other ways that make a bit more sense: 1. (Today) Use the `onBlur` on the input to reset the `query` value to filter options. 2. (In the future) Use an exposed `onClose` (or similar) event to reset your `query` value. * update changelog * ignore flakey test
What package within Headless UI are you using?
@headlessui/react
-Combobox
What version of that package are you using?
1.7.2
What browser are you using?
firefox
Reproduction URL
https://github.com/stefanprobst/headlessui-combobox
Describe your issue
in a
multiple
combobox, the combobox.input value is set to an empty string when clicking outside without selecting anything. however, since this is set directly on the ref, noinput
/change
event is fired, so the searchtermuseState
will not get notified. in this example, you can see that when focusing the combobox input again, the searchTerm is still set to the previously entered phrase, even though the input is empty:combobox.mp4
The text was updated successfully, but these errors were encountered: