Skip to content

Conversation

haoqunjiang
Copy link
Contributor

@haoqunjiang haoqunjiang commented Apr 13, 2025

Fixes #2763.

Using CSS.escape.

As I checked, this API is supported in all browsers even in the 2022 browserslist targets of this project.

Further explanation of the bug:

getComputedStyle() returns a CSSStyleDeclaration, which is serialized according to the spec.
Meanwhile, the values from AnimationEvent are not required to be serialized (which makes sense, as it's intended for JavaScript usage, where escaping for CSS syntax is unnecessary). Therefore the animationName is returned as-is in the event handler, causing the mismatch.


Preview of the bug fix based on the original reproduction: https://stackblitz.com/edit/vitejs-vite-dm8pji1o


I'd like to add a test for this case if it's required—but I don't see any similar tests in Cypress or Storybook, so I don't know what kind of test it should be.

Copy link

changeset-bot bot commented Apr 13, 2025

🦋 Changeset detected

Latest commit: 8b6ce90

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@radix-ui/react-presence Patch
@radix-ui/react-checkbox Patch
@radix-ui/react-collapsible Patch
@radix-ui/react-dialog Patch
@radix-ui/react-hover-card Patch
@radix-ui/react-menu Patch
@radix-ui/react-navigation-menu Patch
@radix-ui/react-popover Patch
@radix-ui/react-radio-group Patch
radix-ui Patch
@radix-ui/react-scroll-area Patch
@radix-ui/react-tabs Patch
@radix-ui/react-toast Patch
@radix-ui/react-tooltip Patch
@radix-ui/react-accordion Patch
@radix-ui/react-alert-dialog Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-menubar Patch
@repo/storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Fixes radix-ui#2763.

Using [CSS.escape](https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape_static).

As I checked, this API is supported in all browsers even in the
[2022 browserslist targets](radix-ui#1019 (comment))
of this project.

Further explanation of the bug:

`getComputedStyle()` returns a `CSSStyleDeclaration`, which is
serialized according to the spec.
Meanwhile, the values from `AnimationEvent` are not required to be
serialized (which makes sense, as it's intended for JavaScript usage,
where escaping for CSS syntax is unnecessary). Therefore the
`animationName` is returned as-is in the event handler, causing the
mismatch.
@haoqunjiang haoqunjiang force-pushed the fix-presence-animation-name-escape branch from 49e599e to 8b6ce90 Compare April 13, 2025 05:06
@chaance chaance merged commit 6406daa into radix-ui:main Aug 13, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

@radix-ui/react-presence doesn't handle the animationend event correctly when keyframe has escapable character
2 participants