motiondivision / motiondivision/motion

[BUG] AnimatePresence with mode=popLayout doesn't consistently trigger opacity exit animations on elements with layout

Open
#2,416 9 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
33.7k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
14

Description

2. Describe the bug

Motion elements with layout and exit animations don't always run their exit animations if they're inside an <AnimatePresence> that has a mode of "popLayout".

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/devbox/github/samselikoff/2023-11-25-framer-motion-pop-layout-bug/tree/main?file=%2Fapp%2Fpage.tsx%3A9%2C11

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Click the "Add item" 4 times
  2. Click on an item. Notice it fades out.
  3. Click another item. Notice it disappears (its exit opacity animation is not triggered)

Behavior seems to continue, where the fade-out only happens for every other item.

5. Expected behavior

Exit animation is always applied.

6. Video or screenshots

https://github.com/framer/motion/assets/2922250/878ecf24-d382-4885-8db6-2765ab8d1e64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction at app/page.tsx, following the listed steps with AnimatePresence mode="popLayout" and elements using layout and exit animations. Trace the relevant Motion and AnimatePresence behavior, then verify that every removed item consistently runs its opacity exit animation.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.