-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
[Dialog, Popover, Menu, Select, PreviewCard] Unify backdrop implementation #841
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy preview |
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.
Menu
didn't have a Backdrop in the first place, but should?
Added. |
@@ -114,6 +114,7 @@ const DialogPopup = React.forwardRef(function DialogPopup( | |||
|
|||
return ( | |||
<FloatingPortal root={container}> | |||
{modal && mounted && <FloatingOverlay />} |
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.
What about z-index
?
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.
Yeah, right, this is going to be tricky. We could figure out the z-index of the popup and set this one lower, but this will be unreliable in some cases. We might have to expose the className
of this part, or the whole part itself, to be consistent with the rest of the API.
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.
Is this another problem solved by a separate Portal part? 😅
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.
Not really, unless I'm missing something. Having an explicit Portal wouldn't help determining the right z-index of the internal backdrop.
Perhaps a better solution is not rendering the internal backdrop, but adding the inert
attribute to all elements except the popup?
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.
Perhaps a better solution is not rendering the internal backdrop, but adding the inert attribute to all elements except the popup?
This could work. guards={false}
on FloatingFocusManager
does this, but it allows escaping to the browser address bar of course, which we didn't want to allow. Guess this is relevant: floating-ui/floating-ui#3098
The other option is to get the computed z-index
style of the Popup
and apply the z-index
to be just one less on FloatingOverlay
?
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.
This could work. guards={false} on FloatingFocusManager does this, but it allows escaping to the browser address bar of course, which we didn't want to allow.
I'll take a look at Floating UI implementation and see what I can do, then (floating-ui/floating-ui#3131)
The other option is to get the computed z-index style of the Popup and apply the z-index to be just one less on FloatingOverlay?
This was my first idea, but I realized someone might style a child of the popup for some reason. Or the z-index could change depending on how many dialogs are open, so this might not be the most reliable solution.
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.
Is the bug that causes the Backdrop
to be inserted into the DOM after the Popup
fixed with this? Not sure why it would occur exactly but I'm assuming the way FloatingPortal
creates a root container could be an issue. There is one minor part that has asynchronicity related to cleanup, but not sure if that would be the cause.
I don't know TBH. I could reproduce it neither on master nor here. |
If its about Backdrop overlaying the Popup, I think I had a transition on the Popup, and no transition on the Backdrop |
I was able to reproduce it consistently (once every ~5-10 times) on master previously when clicking very quickly on the trigger and backdrop - the backdrop did have a normal transition along with the popup. But on latest master, and this PR on the new dialog page, I haven't been able to reproduce it at all. Might be fixed? |
Unified and simplified backdrop implementation:
role: 'presentation'
in all backdropscontainer
prop to DialogBackdrop and AlertDialogBackdroppart of #623