question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Multiple/nested Dialog instances bugs

See original GitHub issue

What package within Headless UI are you using?

@headlessui/react

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 if autoFocusRef 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

4reactions
RobinMalfaitcommented, Apr 22, 2021

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

2reactions
RobinMalfaitcommented, Apr 22, 2021

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 using npm install @headlessui/react@dev or yarn add @headlessui/react@dev.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found