-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase ConfirmDialog overlay's z-index to render above popovers #37959
Increase ConfirmDialog overlay's z-index to render above popovers #37959
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we apply the z-index change to the ConfirmDialog
or to Modal
directly? After all, Modal
's description says:
A modal is a type of floating window that appears in front of content to provide critical information or ask for a decision. Modals disable all other functionality when they appear. A modal remains on screen until the user confirms it, dismisses it, or takes the required action.
In case we do make the change in the Modal
component, we would need to make sure that it doesn't introduce any regressions in other parts of Gutenberg.
Also, could there ever be a case where the popover needs to be rendered on top of a confirm dialog? I can't personally think of any, as in my mind, a modal dialog should render on top of every other UI. But just wanted to double check before going ahead. (cc @diegohaz @mirka )
// Note: The ConfirmDialog component's z-index is being set to 1000001 in packages/components/src/confirm-dialog/styles.ts | ||
// because it uses emotion and not sass. We need it to render on top its parent popover. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted about leaving a comment here.
One more example of how having some components written in Sass and some in CSS-in-JS can damage readability and modularity of this library (cc @mirka as we have already discussed, it'd feel real nice to refactor this to CSS-in-JS)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kudos to @fullofcaffeine for the guidance and suggestions regarding the commenting 😄
I had the same thoughts, until I saw the base styles, where it looks like popovers are rendered above modals intentionally - so I'm guessing there's some logic/nuance I'm not thinking of 🤔 |
Hey @diegohaz @youknowriad @jasmussen (sorry for the ping!), do you have any insights on if and why popovers may be intentionally rendered on top of modals? Thank you! |
Sure, I guess dropdowns and tooltips for UIs rendered inside a modal. |
<Modal>
<Tooltip text="world">
<span>hello</span>
</Tooltip>
</Modal> ^ Given that this kind of thing is already not working, I would think it's not really something that can be fully addressed by z-index alone. Should we reconsider where the portals are inserted, and/or whether the stacking contexts are properly isolated? |
Yes, the root of the cause definitely seems to be related to these components not rendering in the correct stacking context — although I'm not super familiar with how exactly they render, and I assume that we would need to investigate what's the best approach here that would allow us to make improvements without introducing breaking changes. Should we also abandon the changes proposed in this PR, since they would introduce a regression where dropdowns/tooltips are supposed to render on top/within a modal? |
Thank you @chad1008 for looking more into this! I'm going to write down a few considerations:
|
Sounds logical to me. As you say, the overflow issue feels like a separate, larger issue that should be addressed separately. I'm in favor of adjusting the z-index to address the short term ConfirmDialog needs for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably the better thing to do, at the moment, is to apply a higher z-index only to ConfirmDialog (like this PR suggests), in order to unblock the set of PRs using that component.
What do folks think?
@ciampo Agreed! Given you already pre-approved this this solution is isolated to the ConfirmDialog
component and that it tests well with #37602, I'm approving this now.
Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
b73520e
to
6b753dd
Compare
Done! thank you all for the review and input! |
Description
This PR increases the z-index value for the new
ConfirmDialog
component so it will render above any Popovers.By default, Popovers render above everything, with some limited exceptions. In the case of
ConfirmDialog
, this means that if the dialog is the child component of such aPopover
, the parent component renders above the confirmation dialog.How has this been tested?
To test, we first need an active example of
ConfirmDialog
, which is still being implemented.confirm()
toConfirmDialog
#37602PostVisibility
component that renders, select PrivatePostVisibility
popover (the popover should appear below the scrim along with the rest of the elements on the page)Tested in latest Chrome with GB 6.0-alpha-52573 via wp-env.
Checklist:
*.native.js
files for terms that need renaming or removal).