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

Combobox improvements #1101

Merged
merged 7 commits into from
Feb 10, 2022
Merged

Combobox improvements #1101

merged 7 commits into from
Feb 10, 2022

Conversation

RobinMalfait
Copy link
Member

This PR contains a bunch more improvements after internal testing and dog fooding the component.

These are implemented on the `Combobox.Option` instead of the
`Combobox.Options`. This allows you to have additional visual padding
between `Combobox.Options` and `Combobox.Option` and if you hover over
that area then the option becomes inactive.

If we implement it on the `Combobox.Options` instead then this isn't
_that_ easy to do. We can do it by checking the target and whether or
not it is inside a headlessui-combobox-option. This would only have a
single listener instead of `N` listeners though. Potential improvements!
@vercel
Copy link

vercel bot commented Feb 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/Fv8h1q3htFVr2yNSHyz3A8tTZ2do
✅ Preview: https://headlessui-react-git-combobox-improvements-tailwindlabs.vercel.app

headlessui-vue – ./packages/playground-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/DUdRdU62EdzVDN2JWh8GwokAM6uH
✅ Preview: https://headlessui-vue-git-combobox-improvements-tailwindlabs.vercel.app

@@ -111,7 +114,8 @@ let reducers: {
},
[ActionTypes.GoToOption](state, action) {
if (state.disabled) return state
if (state.comboboxState === ComboboxStates.Closed) return state
if (!state.optionsPropsRef.current.static && state.comboboxState === ComboboxStates.Closed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to treat a combobox with static options as always open or would that break more things?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it might be okay for the combobox but not required. We can't do it for a Listbox / Menu because of focus trap / tab trap behaviour that is enabled based on that open / closed state. So maybe for that reason alone we shouldn't do it here either for consistency?

Copy link
Contributor

@thecrypticace thecrypticace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question (which the answer itself doesn't really necessitate changes one way or the other) but otherwise LGTM 👍

You’ve taken control of the open/close state yourself in which case this should be allowed to be handled by other event handlers
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.

2 participants