-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
immediate
prop to <Combobox />
for immediately opening the Co…
…mbobox when the `input` receives focus (#2686) * Allow to open combobox on input focus * Close focused combobox with openOnFocus prop when clicking the button * ensure tabbing through a few fields, doesn't result in an incorrectly selected item When you have a fwe inputs such as: ```html <form> <input /> <input /> <input /> <Combobox> <Combobox.Input /> </Combobox> <input /> <input /> <input /> </form> ``` Tabbing through this list will open the combobox once you are on the input field. When you continue tabbing, the first item would be selected. However, if the combobox is not marked as nullable, it means that just going through the form means that we set a value we can't unset anymore. We still want to open the combobox, we just don't want to select anything in this case. * only `openOnFocus` if the `<Combobox.Input />` is focused from the outside If the focus is coming from the `<Combobox.Button />` or as a side effect of selecting an `<Combobox.Option />` then we don't want to re-open the `<Combobox />` * update tests to ensure that the `Combobox.Input` is the active element * order `handleBlur` and `handleFocus` the same way in Vue & React * only select the active option when the Combobox wasn't opened by focusing the input field * convert to `immediate` prop on the `Combobox` itself * update changelog * ensure we see the "relatedTarget" in Safari Safari doesn't fire a `focus` event when clicking a button, therefore it does not become the `document.activeElement`, and events like `blur` or `focus` doesn't set the button as the `event.relatedTarget`. Keeping track of a history like this solves that problem. We already had the code for the `FocusTrap` component. --------- Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
- Loading branch information
1 parent
5a1e2e4
commit fa95262
Showing
12 changed files
with
870 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
fa95262
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
headlessui-vue – ./packages/playground-vue
headlessui-vue-tailwindlabs.vercel.app
headlessui-vue-git-main-tailwindlabs.vercel.app
headlessui-vue.vercel.app
fa95262
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
headlessui-react – ./packages/playground-react
headlessui-react.vercel.app
headlessui-react-tailwindlabs.vercel.app
headlessui-react-git-main-tailwindlabs.vercel.app