motiondivision / motiondivision/motion

[BUG] Using `layoutRoot` on the parent causes degradation of performance in `Reorder` component

Open
#2,425 1 comment 1 reaction 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

1. Read the FAQs 👇

2. Describe the bug

Using layoutRoot on the parent causes degradation of performance in Reorder component.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/framer-motion-variants-forked-kwqsnd?file=%2Fsrc%2FApp.tsx

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Create a parent with open and closed variants with different scales.
  2. Create a Reorder.Group with layout and layoutRoot properties.
  3. Create a few Reorder.Item.
  4. Toggle the parent's variant and observe the Reorder.Group correctly follow the parent.
  5. Reorder the Reorder.Item and observe degradation in performance and jittery motion.

5. Expected behavior

Adding layoutRoot should not affect the performance of the Reorder component. If layout is causing the issue, it would be good to be able to set only layoutRoot without layout.

6. Video or screenshots

https://github.com/framer/motion/assets/455178/fe153434-a941-4c28-bec1-36da6517ac8b

7. Environment details

Google Chrome: 119.0.6045.159
MacOS: Sonoma 14.0
Framer-motion: 10.16.5
React: 18.2.0

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 CodeSandbox reproduction in src/App.tsx and verify the performance difference when reordering with the parent variant and Reorder.Group using layout and layoutRoot. Trace the Reorder component's layout handling, then confirm that toggling the parent and reordering items no longer causes jitter or degradation without regressing the parent transition.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.