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] AnimatePresence sometimes does remove elements when two or more elements are removed in a short time. #1624

Closed
jancassio opened this issue Jul 18, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@jancassio
Copy link

jancassio commented Jul 18, 2022

1. Read the FAQs 👇

2. Describe the bug
Using AnimatePresence element to remove elements with exit animation works but sometimes does not remove all elements from the render tree.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
Demo reproducing the problem here

4. Steps to reproduce

  1. Type some text in the input field
  2. See an animation right below of characters appearing animated.
  3. Also, see a "caret" icon at the right, pay attention to the distance between the last typed char and the caret.
  4. Remove some text by typing backspace faster or press and hold backspace to remove some text.
  5. Notice there's a larger distance between the last character and the caret.
  6. Use the DevTools -> Elements (or right click, "Inspect)" to inspect the dom.
  7. Notice the are some elements that already performed exit transition but weren't removed from the element's tree.

5. Expected behaviour

The expected behaviour is for the all removed characters to perform an exit transition and be removed from the element's tree.
Also, the visible expected behaviour is to the "cared" always be immediately at the right of the last visible character.

A clear and concise description of what you expected to happen.

6. Video or screenshots

framer-motion-animated-presence-bug.mov

7. Environment details

All running in macOS Monterey (12.4) Intel-based machine.

Browser Version
Brave 1.41.96
Chrome 103.0.5
Safari 15.5
Firefox 102.0.1

The same issue is also reproducible at Safari running at iOS 15.1.

Updates

  • Original issue has been found at v6.5.1.
  • Reproduced with v7.0.0.
@jancassio jancassio added the bug Something isn't working label Jul 18, 2022
@jancassio
Copy link
Author

Related to: #1569

@JPaulDev
Copy link

Having a similar issue, I have couple elements that I remove on window resize, if I resize the window too quickly elements complete their transition animation then don't get removed from the DOM and end up stuck there.

@julio-benavente
Copy link

I haven't been able to solve the problem but using a hook to slow the frequency my function was called helped me to avoid crashes. It doesn't behave as I would like but it doesn't crash.

https://usehooks-ts.com/react-hook/use-debounce

@mattgperry
Copy link
Collaborator

Fixed in latest

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

4 participants