You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Popovers and other UI should not appear on top of modal dialog overlays #55894
It is worth mentioning that no other UI should appear on top of a modal dialog overlay so this is not limited to popovers but applies to any other UI that potentially may have the same incorrect behavior.
This is a fair point, and potentially a tricky one to solve:
the main issue is that many popover-based components do not have the concept of "modality" (only Modal does), and as a result, these components can be open at the same time. We are slowly working towards it by migrating our components to internally use ariakit, which natively supports "modality" for these components
for command palette may pose a slightly different challenge, since it implemented using a different third-party library (which I believe uses radix-ui in the background). So we'd need to somehow have a way for the command palette to notify the rest of the app that any other modal-like piece of UI should be hidden when the palette is opened.
Trying to inspect all the z-indexes with very high value I just noticed that also the new dropdown powered by ariakit uses a too high z-index value. The value is hardcoded in the component. I do realize why but that should be improved as noted in the comments in the code.
Screenshot of a dropdown menu appearing on top of a modal dialog overlay:
One aspect to consider is that popover-based components (eg. dropdown menus, tooltips) can also be rendered inside a modal dialog, and therefore it's not straightforward to come up with z-index rules that work across all scenarios.
One aspect to consider is that popover-based components (eg. dropdown menus, tooltips) can also be rendered inside a modal dialog, and therefore it's not straightforward to come up with z-index rules that work across all scenarios.
Could these be modified to render within the modals. Doing so would resolve the issue as the popover would be created within the modal's stacking context.
One aspect to consider is that popover-based components (eg. dropdown menus, tooltips) can also be rendered inside a modal dialog, and therefore it's not straightforward to come up with z-index rules that work across all scenarios.
Could these be modified to render within the modals. Doing so would resolve the issue as the popover would be created within the modal's stacking context.
If they render within the modal in the DOM, overflow issues might happen (with overflow: hidden, overflow: auto, overflow: scroll, and so on).
A different approach is to set up a React Context-based z-index stack. This way, nested dialogs can increase the z-index they obtain from the context based on the React tree, even if they're appended to another DOM node using React Portal.
Worth reminding there was also a problem with tooltips within the modal dialog, in the Site Editor and on mobile. See #47614 (comment) that was fixed only coincidentally with the refactoring of the tooltips with ariakit in #48440
It would be great to take into account all the potential cases and add E2E tests for each of them.
Overall, I'd like to reach a point where our popover-based UIs (modal or not) render correctly on top of each other, following the react tree nesting, and thus allowing us to move away from hardcoded z-index values (unless there's a real need).
For the rare cases where, while some modal UI is rendered on screen, a new piece of non-nested modal UI needs to be rendered (like in the issue's description), we have two choices:
we close the existing modal UI, before opening the new one
we prevent the new one from opening
Whatever solution we adopt, we'd likely need something like a global "modal context" to manage the logic.
Activity
afercia commentedon Nov 6, 2023
It is worth mentioning that no other UI should appear on top of a modal dialog overlay so this is not limited to popovers but applies to any other UI that potentially may have the same incorrect behavior.
ciampo commentedon Nov 6, 2023
This is a fair point, and potentially a tricky one to solve:
Modaldoes), and as a result, these components can be open at the same time. We are slowly working towards it by migrating our components to internally useariakit, which natively supports "modality" for these componentsradix-uiin the background). So we'd need to somehow have a way for the command palette to notify the rest of the app that any other modal-like piece of UI should be hidden when the palette is opened.afercia commentedon Nov 6, 2023
Thanks @ciampo for your feedback. I think there are two different aspects to consider here:
The current z-index value for popovers is higher than the one for the modal dialog overlay:
afercia commentedon Nov 6, 2023
Trying to inspect all the z-indexes with very high value I just noticed that also the new dropdown powered by ariakit uses a too high z-index value. The value is hardcoded in the component. I do realize why but that should be improved as noted in the comments in the code.
Screenshot of a dropdown menu appearing on top of a modal dialog overlay:
ciampo commentedon Nov 6, 2023
One aspect to consider is that popover-based components (eg. dropdown menus, tooltips) can also be rendered inside a modal dialog, and therefore it's not straightforward to come up with z-index rules that work across all scenarios.
peterwilsoncc commentedon Nov 7, 2023
Could these be modified to render within the modals. Doing so would resolve the issue as the popover would be created within the modal's stacking context.
diegohaz commentedon Nov 20, 2023
If they render within the modal in the DOM, overflow issues might happen (with
overflow: hidden,overflow: auto,overflow: scroll, and so on).A different approach is to set up a React Context-based z-index stack. This way, nested dialogs can increase the z-index they obtain from the context based on the React tree, even if they're appended to another DOM node using React Portal.
afercia commentedon Nov 20, 2023
Worth reminding there was also a problem with tooltips within the modal dialog, in the Site Editor and on mobile. See #47614 (comment) that was fixed only coincidentally with the refactoring of the tooltips with ariakit in #48440
It would be great to take into account all the potential cases and add E2E tests for each of them.
ciampo commentedon Nov 22, 2023
Overall, I'd like to reach a point where our popover-based UIs (modal or not) render correctly on top of each other, following the react tree nesting, and thus allowing us to move away from hardcoded
z-indexvalues (unless there's a real need).For the rare cases where, while some modal UI is rendered on screen, a new piece of non-nested modal UI needs to be rendered (like in the issue's description), we have two choices:
Whatever solution we adopt, we'd likely need something like a global "modal context" to manage the logic.
afercia commentedon Dec 28, 2023
One more evident case after #56817 is when creating a new template in the post editor:
Cc @youknowriad
Screenshot: