Skip to content
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 overlay flashing in React 19 #665

Open
Semesse opened this issue Jan 3, 2025 · 2 comments
Open

Dialog overlay flashing in React 19 #665

Semesse opened this issue Jan 3, 2025 · 2 comments

Comments

@Semesse
Copy link

Semesse commented Jan 3, 2025

Closing the Dialog causes the overlay to have a high chance to flash

Repro: https://codesandbox.io/p/sandbox/42tyf8

From my investigation it seems to relate to this, after setting animationFillMode to forwards the overlay becomes visible again
image

@dann-dann
Copy link

Experiencing same issue.

This solution worked for me
radix-ui/primitives#3286 (comment)

@Sang-minKIM
Copy link

I suspect the flickering occurs because the dialog close and overlay fade-out are running as separate animations with different timings. It seems that these multiple animation keyframes were causing visual inconsistencies when conflicting with each other. The issue can be resolved by replacing animations with transitions for the closing state.

Here's the solution that worked for me:

.rt-BaseDialogOverlay {
  &:where([data-state='closed']) {
    animation: none !important;
  }
  &:where([data-state='open'])::before {
    animation: rt-fade-in 150ms cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  &:where([data-state='closed'])::before {
    animation: none !important;
    opacity: 0;
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
  }
}

.rt-BaseDialogContent {
  &:where([data-state='open']) {
    animation: rt-dialog-content-show 150ms cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  &:where([data-state='closed']) {
    animation: none !important;
    opacity: 0;
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants