Nested dialogs
See original GitHub issueFirst of all, thanks and congrats for such a small, elegant and accessible dialog solution š
Error
I step into an error while opening a modal from within another dialog, so multiple modals opened at the same time. (everything kept working, but the following error logs to console)
Note: If this is the expected behaviour, as in, we shouldnāt open more than one dialog at once, ignore this report and close it.
Demo
Steps:
- Open Modal one
- Open modal two from modal 1 content
- look at console
Error log
Maximum call stack size exceeded.
at o ((index):72)
at e._maintainFocus ((index):72)
Details
version: ^4.0.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to Create nested Dialog in JavaScript (ES5) Dialog control
A Dialog can be nested within another Dialog. The below sample contains parent and child Dialog (inner Dialog). Step 1: Create two div...
Read more >Nested dialogs
Nesting dialogs is a questionable design pattern that is not referenced anywhere in the HTML 5.2 Dialog specification.
Read more >Nested Dialog MenuItem Dropdown - CodeSandbox
Nested Dialog MenuItem Dropdown. https://github.com/mui-org/material-ui/blob/master/docs/src/pages/components/dialogs/FormDialog.js.
Read more >Nested dialogs - HyvƤ Docs
Nested dialogs. Modals can be displayed from within another dialog. The only requirement is that each dialog has a unique Alpine.js x-ref name....
Read more >Nested dialogs - JSFiddle - Code Playground
<p>This is a nested dialog for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>.
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
@HugoGiraudel Iāve back to this.
It was apparently a simple fix. If the
event.target
has attributedata-a11y-dialog-show
that is not equal to instance node referencethis.node.id
then we are in the presence of another dialog, so skip the setFocusTofirstItem onthis
instance for now, that will be triggered later again when the second modal opens and that time it will evalute to true and focus the correct itemThis appears to work fine butā¦
Easy tiger
This only works for click events. But weāre talking about an accessible dialog. We still need to handle other input methods, keyboard, and the problem is not at the opening but when we close.
escape click signal ever instance to fire itās
.hide()
method.That is not a bad default behaviour and we could end this conversation here butā¦
what if want to close only the last opened?
Each instance is isolated and has no idea about the state their siblings, by design. So we canāt call it a problem. That being said a couple of workarounds came to my mind to solve this.
and then we could check for open dialog siblings on āescape clickā
And then same on Escape click event
Note:
focusedBeforeDialog
behaviour starts failing if we have >2 dialogs. I have no eloquent explanation for this yet, but saving this element on the constructor asthis.focusedBeforeDialog
solves it.demo here
Final Notes
Iām still not happy with any of this solutions because they are no-solutions. Weāre relying on DOM order to check for the top most Dialog and i donāt like the smell of that idea. I donāt like to dictate how other people should organize their DOM, i donāt event know if the dialog is there at DOM load.
Shameless question (request for advice/help): how would you handle it? from top of my mind:
data-a11y-dialog-order=""
on open, by checking other opened instancesIāve back to this because:
Well thatās a wrap, sry for the long post! Cheers!
@HugoGiraudel Sure, iāll gladly do it!