-
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
Close the Combobox
, Dialog
, Listbox
, Menu
and Popover
components when the trigger disappears
#3075
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
1073680
to
e8106d2
Compare
Menu
, Listbox
, Popover
and Dialog
components when the triggers disappearMenu
, Listbox
, Popover
and Dialog
components when the trigger disappears
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- Accept optional `strategy` for the `anchor` prop ([#3034](https://github.com/tailwindlabs/headlessui/pull/3034)) | |||
- Expose `--input-width` and `--button-width` CSS variables on the `ComboboxOptions` component ([#3057](https://github.com/tailwindlabs/headlessui/pull/3057)) | |||
- Expose the `--button-width` CSS variable on the `PopoverPanel` component ([#3058](https://github.com/tailwindlabs/headlessui/pull/3058)) | |||
- Close the `Menu`, `Listbox`, `Popover` and `Dialog` components when the trigger disappears ([#3075](https://github.com/tailwindlabs/headlessui/pull/3075)) |
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.
Alphabetical 🤷♂️
- Close the `Menu`, `Listbox`, `Popover` and `Dialog` components when the trigger disappears ([#3075](https://github.com/tailwindlabs/headlessui/pull/3075)) | |
- Close the `Dialog`, `Listbox`, `Menu`, and `Popover` components when the trigger disappears ([#3075](https://github.com/tailwindlabs/headlessui/pull/3075)) |
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.
Just thinking — should this behavior not be added to the Combobox
as well?
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.
I completely missed this one, 100% should be added there as well!
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.
Looks good! Mostly just wondering if we need this behavior on the Combobox
as well?
Menu
, Listbox
, Popover
and Dialog
components when the trigger disappearsCombobox
, Dialog
, Listbox
, Menu
and Popover
components when the trigger disappears
9a6e17e
to
c9f9182
Compare
This hook allows us to trigger a callback if the element becomes "hidden". We use the bounding client rect and check the dimensions to know wether we are "hidden" or not.
c9f9182
to
67243b9
Compare
This PR will ensure that we don't have any floating panels when the trigger elements disappear. We already had this implementation for the
Dialog
component, but now this is implemented for all components that have ananchor
prop.The big problem is that with the
anchor
prop, each panel (e.g.:MenuItems
,ListboxOptions
, …) is portalled and positioned relative to theanchor
element. If theanchor
element disappears, the panel will still be rendered and strangely positioned in the DOM, which is not the desired behavior.This PR solves that by:
Combobox
, when theComboboxInput
disappearsDialog
, when theDialog
itself disappears (this was already implemented, but now it's using the newuseOnDisappear
hook)Listbox
, when theListboxButton
disappearsMenu
, when theMenuButton
disappearsPopover
, when thePopoverPanel
disappears