How should we handle nested modals? #1861
Unanswered
marceloclp
asked this question in
Help
Replies: 1 comment 1 reply
-
Something like this? https://codesandbox.io/s/distracted-bell-4kz878?file=/App.js |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to use dialogs (or modals) to create a SPA-like experience. To illustrate what I want to build, take a look at the following code:
Notice that modals are nested within each other.
In short, a group of modals (or dialogs) should be treated as a single modal. That means:
The main issue with this is that once we open modal 2, modal 1 will unmount which means modal 2 doesn't exist on the tree anymore, becoming unable to be rendered. There are ways to overcome this issue, like pushing the modal into state and rendering it somewhere else:
Another way is to not unmount the modal, and just hide it with CSS, but this could cause a lot of other issues that I would like to avoid.
However, I am not sure this is the correct approach. It feels over engineered, and now I have to fight back against the trigger no longer being focused back automatically, etc, etc, etc.
Another simpler solution is to simply replace the content of the dialog. My knowledge of accessibility is somewhat limited, so I simply assumed that to get the full accessibility benefits I needed to render a modal for each content. Is this assumption correct?
Beta Was this translation helpful? Give feedback.
All reactions