headlessui icon indicating copy to clipboard operation
headlessui copied to clipboard

Sibling/nested dialogs: Wrong dialog is closed when the first dialog is open at mount time, when using StrictMode

Open nuschk opened this issue 7 months ago • 0 comments

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

2.1.0

What browser are you using?

Chrome, Safari

Reproduction URL

https://playcode.io/1918392

Describe your issue

  • App starts, shows the first dialog already open
  • Click the button "Open 2.", which opens the second dialog
  • Try to edit the input field on the second dialog, doesn't work.
  • Try to click on the title of the second dialog, second dialog is wrongly closed

Sorry for the long title, didn't know how to get it more concise 🫣. It only happens when using <StrictMode /> , although I must say, IME, that always points to a real error, so I suspect it's a bug.

BTW, my use-case is the dialog is bound to a specific URL in a tanstack-router app.

Also:

  • Nested dialogs don't work either, same behaviour
  • When the second dialog starts as open, we get the same behaviour
  • Workaround is to open the dialog with a requestAnimationFrame, in which case it works.
  • Or, you know, remove <StrictMode/>

And thank you so much for making sibling dialogs work! I've been waiting for it since... ever!

nuschk avatar Jun 26 '24 09:06 nuschk