Skip to content

Dialog Close Animation Flicker #8802

@colinmorelli

Description

@colinmorelli

Provide a general summary of the issue here

It appears that the exit animation of dialogs is not being handled correctly, or I'm somehow misusing it.

🤔 Expected Behavior?

Dialogs/modals should show the exit animation, and then remove the elements from the DOM when the animation is complete.

😯 Current Behavior

The exit animation begins, and then often begins a second time, resulting in either an animation flicker or, in some cases, the element permanently remaining on screen.

💁 Possible Solution

I haven't been able to identify the cause yet, other than to say it seems to not be a state management issue with the dialog. The isOpen state is definitely set to false, once time, but the animation appears twice. In the cases where the element remains permanently on screen, isOpen is still set to false, indicating the issue is with animation handling. Indeed, removing animations from the elements works and ensure the dialog is always mounted/unmounted correctly.

🔦 Context

I'm not sure this context is worth much, but this did not seem to be happening two days ago. Or at least, I had not seen it happen. However, now, I can't get it to stop. Even downgrading react-aria does not seem to fix it. So either I was incorrect, and it was happening before, or something else (like a Chrome update) triggered the behavior.

🖥️ Steps to Reproduce

You should be able to see the behavior on this sandbox. Just click the open dialog button, and then the close dialog button. Pay attention to the close animation. It is regularly triggering twice for me. In my own application, the dialog sometimes also fails to close entirely. The exit animation shows, but the dialog reappears on screen after and is unresponsive. When I've been able to replicate this, the dialog state believes that it's closed, but the element is stuck with data-exiting animation set to true.

https://codesandbox.io/p/sandbox/dazzling-butterfly-d6xjvq

(Note: Apologies for the messy CSS. I just ripped my generated tailwind file and threw it in the codesandbox. I don't think the CSS declarations themselves are the problem, but perhaps they are).

Version

react-aria 3.43.1, react-aria-components 1.12.1

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS Tahoe (26)

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions