Skip to content
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

Don’t drop initial character when searching in Combobox #1223

Merged
merged 2 commits into from
Mar 9, 2022

Conversation

thecrypticace
Copy link
Contributor

In the Vue version of the combobox the input is synced when the combobox state changes. This is done because closing the combobox needs to reflect the current selected value. For example, pressing the Escape key after searching should revert to what the value was before the user started searching.

However, doing this on open is problematic:

  1. Typing in the input field will open the combobox if it's not open already.
  2. Opening the combobox causes the internal state to change.
  3. This state change causes the input to be synced.

All three of these steps happen in the same render cycle. This causes the value that would've been written by the input event to be lost because the value is synced with the old value that is currently in state. This manifested as the first character causing the combobox to open but not adding (or replacing if there was a selection) characters in the input.

@vercel
Copy link

vercel bot commented Mar 9, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

headlessui-react – ./packages/playground-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/7872eguDEfLaVDxukE8Tmfth5R4W
✅ Preview: https://headlessui-react-git-fix-combobox-initial-k-2501c0-tailwindlabs.vercel.app

headlessui-vue – ./packages/playground-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/8rQDqbvhV1dj9xTjjL4j3rCVK97c
✅ Preview: https://headlessui-vue-git-fix-combobox-initial-key-42d3cd-tailwindlabs.vercel.app

@thecrypticace
Copy link
Contributor Author

Merging cause I really need a new insiders build with this fixed 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant