-
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
Nested Popovers not closing on click outside #3332
Comments
This should be fixed by #3362, and will be available in the next release. You can already try it using:
|
Thanks @RobinMalfait for looking into the issue. Using the insider build, after opening a parent popover and then a nested popover, on click outside will close the nested popover ✅, BUT will leave the parent popover open In the updated sandbox you can see that clicking a button or focusing an input outside of popovers closes both the parent and nested popovers, and I think it's reasonable to expect a click outside to have the same effect, like in Let me know if anything is unclear and thanks again |
Hey @raduflp! This was actually incorrect behaviour in v2.0.4 which we improved in v2.1. The idea is that it closes one level of the stack at a time. However, the Similarly, if you are using the keyboard, pressing esc also closes 1 level at a time instead of everything at once. For example you can image where you have a form in the first This is also the case for other components, for example when you have nested What's your use case for closing everything when clicking outside? |
Our use case is a complex dashboard that lets the user drill down in a deeply nested tree structure. So if a user drills down down 3 levels deep, to return to level 2 he would click on the parent popover. The I can totally see the use case when you would want to close on popover at a time, probably that should be the default behavior. But maybe there should be an escape hatch for when that behavior is not desirable. |
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v2.1.0
What browser are you using?
Chrome
Reproduction URL
https://codesandbox.io/p/devbox/confident-pasteur-ly35gk?file=%2Fsrc%2FApp.jsx%3A25%2C1
Describe your issue
In
v.2.0.4
and before nested popups would close when clicking outside of thePopoverPanel
Starting with
v2.1.0
a nested Popovers close only when clicking within the parent Popover or when focusing inputs outside of the popoversThe text was updated successfully, but these errors were encountered: