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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Exit animation won't trigger after expanding animation of Reach Disclosure completes #1577

Closed
Polm1 opened this issue Jun 9, 2022 · 1 comment
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@Polm1
Copy link

Polm1 commented Jun 9, 2022

1. Read the FAQs 馃憞

2. Describe the bug

As title, exit animation will trigger only before expanding animation will completes and disclosure is closed instantly.

Animating straight the DisclosurePanel is even worse because some side-effect will cause animation stutterings (maybe to related to suggested "height: "auto" is jumping" on the Faqs below in this template)

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/s/framer-motion-reach-disclosure-0dvljh?file=/src/Example.tsx

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Open console
  2. Click on button to open disclosure
  3. Await to -- animation complete -- log
  4. Click again on button to close disclosure and see that it closes instantly

To see exit animation, quickly click again on button to close disclosure before -- animation complete --` log

5. Expected behavior

Exit animation should trigger even after animation completed

6. Video or screenshots

7. Environment details

React 17.0.2

Styled components 5.3.5

Reach/Disclosure 0.17.0

Framer Motion 6.3.11

FAQs

height: "auto" is jumping

Animating to/from auto requires measuring the DOM. There's no perfect way to do this and if you have also applied padding to the same element, these measurements might be wrong.

The recommended solution is to move padding to a child element. See this issue for the full discussion.

Type error with AnimateSharedLayout

AnimateSharedLayout was deprecated in 5.0. Refer to the upgrade guide for instructions on how to remove.

Preact isn't working

Framer Motion isn't compatible with Preact.

AnimatePresence isn't working

Have all of its immediate children got a unique key prop that remains the same for that component every render?

// Bad: The index could be given to a different component if the order of items changes
<AnimatePresence>
  {items.map((item, index) => <Component key={index} />)}
</AnimatePresence>
// Good: The item ID is unique to each component
<AnimatePresence>
  {items.map((item, index) => <Component key={item.id} />)}
</AnimatePresence>

Is the AnimatePresence correctly outside of the controlling conditional? AnimatePresence must be rendered whenever you expect an exit animation to run - it can't do so if it's unmounted!

// Bad: AnimatePresence is unmounted - exit animations won't run
{isVisible && (
  <AnimatePresence>
    <Component />
  </AnimatePresence>
)}
// Good: Only the children are unmounted - exit animations will run
<AnimatePresence>
  {isVisible && <Component />}
</AnimatePresence>
@Polm1 Polm1 added the bug Something isn't working label Jun 9, 2022
@Polm1 Polm1 changed the title [BUG] With Reach Disclosure exit animation won't trigger after animation complete [BUG] With Reach Disclosure exit animation won't trigger after expanding animation completes Jun 9, 2022
@Polm1 Polm1 changed the title [BUG] With Reach Disclosure exit animation won't trigger after expanding animation completes [BUG] Exit animation won't trigger after expanding animation of Reach Disclosure completes Jun 9, 2022
@mattgperry mattgperry added the wontfix This will not be worked on label Jan 3, 2024
@mattgperry
Copy link
Collaborator

I'm not sure how the Disclosure component works but this works when changing to a div so this is a wontfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants