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

[BUG] Animating height from "0" to "auto" is broken if also changing display from "none" to "block" #2995

Open
tehapo opened this issue Jan 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@tehapo
Copy link

tehapo commented Jan 13, 2025

Description

We have an accordion that animates height between auto and 0 when expanding/collapsing. In addition to height animation, we switch the display property between block and none in order to make sure the content is hidden also from screen readers.

However, when upgrading our framer-motion dependency, I noticed this behavior is broken with versions >= v11.2.0. When expanding the accordion, the height jumps instantly to auto instead of animating from 0. If the display property is not animated at the same time, the height animation works correctly. On version v11.1.9, the animation still works as expected when applying the display: none in the transitionEnd (in effect transitionEnd: { display: "none" }).

CodeSandbox

Please check this CodeSandbox which is modified version of dev/react/src/examples/Animation-display-visibility.tsx example, which illustrates the issue.

  1. Open the CodeSandbox and open DevTools console to see the console.log output.
  2. Click on the toggle button to see how height animates from auto to 0.
  3. Click again to see how height instantly jumps from 0 to auto without animating.
  4. Repeat steps with the second example to see how height is animated when display property is not animated.

height-bug

@tehapo tehapo added the bug Something isn't working label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant