-
Notifications
You must be signed in to change notification settings - Fork 889
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
No exit animation when dialog content is wrapped #3324
Comments
The animation breaking when the dialog structure isn’t followed is expected. However, If you're using styled components or another styling method instead of CSS classes, you can use the Just make sure the child component accepts a import React from 'react';
import { forwardRef } from 'react';
const CustomContent = forwardRef(({ children, ...props }, ref) => (
<div ref={ref} {...props}>
{children}
</div>
));
// Usage with Dialog.Content
<Dialog.Content asChild>
<CustomContent>
{/* Your content here */}
</CustomContent>
</Dialog.Content> This ensures the component works seamlessly with |
Because the wrapper covers the entire screen (like an invisible backdrop), this will break the dismiss functionality when clicking outside the content because it's the size of the entire screen. I've updated the example with an <Dialog.Root>
<Dialog.Trigger>Open inner wrapper dialog</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Content className="wrapper transition">
<div className="content">Content</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root> I need the wrapper for layouting purposes, not because of component nesting. You could probably also hack your way around with the inner wrapper, but that's probably even more fragile than the portal workaround. If the portal component needs direct access to the content child, is there a way to pass it the reference? |
Bug report
Current Behavior
When wrapping the
Dialog.Content
component, the exit animation does not play (or is not waited for):Expected behavior
It should play the exit animation just like a dialog without a wrapper.
Reproducible example
https://codesandbox.io/p/sandbox/t7xqxz
Workaround
The behavior of a flex wrapper can probably be matched with a lot of CSS trickery on the dialog content. Another alternative is using another external Portal to create the wrapper:
Additional Context
The issue seems to have been around for over 2 years, as I figured out the cause through this discussion comment:
#1534 (reply in thread)
Your environment
@radix-ui/react-dialog
1.1.4
134.0
&131.0.6778.264
The text was updated successfully, but these errors were encountered: