[Bug]: Multiple/nested Dialog instances bugs
See original GitHub issueWhat package within Headless UI are you using?
What version of that package are you using?
1.0.0, 1.0.0-ef31bbe
What browser are you using?
Chrome MacOs, Chrome Android, Safari iOS
Reproduction repository
https://codesandbox.io/s/headlessui-dialog-multiple-modals-bugs-sq7sn?file=/pages/index.js
Describe your issue
First of all, thanks for great library!
In complex app sometimes content of dialog can open another one… I played around dialog component and find some issues:
- scroll jumping, described here: #421 (and I found fix… maybe we should describe this behaviour in documentation)
- if dialog open another dialog:
FocusTrap
- can handle focus only ifautoFocusRef
provided (compare pressing"Open 1" -> "Open 2"
and"Open 1" -> "Open 3"
) - when 2 or more dialogs is open - the are no way to close only one of them
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
JDK-4088877 Multiple modal dialogs can be created ... - Bug ID
PUBLIC COMMENTS Problem is that modal dispatcher thread is fired up _before_ dialog actually appears. It is during this interval (can be several...
Read more >Problem: Dialog nested dialog with modal=true
Problem : Dialog nested dialog with modal=true ... is only one of this cases. We could fix many bugs by getting rid of...
Read more >Full Text Bug Listing - Bugs - Eclipse
I've built a prototype of nested command stacks: - The widgets have to know how to start a nested transaction. As the widgets...
Read more >Headlessui Dialog - multiple modals bugs (forked)
Headlessui Dialog - multiple modals bugs (forked). 1. Embed Fork Create Sandbox Sign in. Sandbox Info. Headlessui Dialog - multiple modals bugs (forked)....
Read more >Bug when associating parameters of shared nested family
5 associate the 'associate' instance parameter of the nested shared ... @ekkonap Bugs should be reported to Autodesk Support through your ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey! Thank you for your bug report! Much appreciated! 🙏
When you want nested Modals, then you should also nest it in the component tree. This allows us to create a stacking context so that when you press
esc
that only the top most Dialog gets closed.Dialogs have this feature where all other content is inert, meaning 2 open Dialogs at the same time is not possible when they are rendered as children. But the nesting should fix this.
Here is an example: https://codesandbox.io/s/headlessui-dialog-multiple-modals-bugs-forked-o2ykb?file=/pages/index.js
Good catch @sveisvei!
I saw it too when I made that example. Have a fix already: https://github.com/tailwindlabs/headlessui/pull/430
Edit: Updated the codesandbox with the
dev
build of Headless UI. You can already try it usingnpm install @headlessui/react@dev
oryarn add @headlessui/react@dev
.