motiondivision / motiondivision/motion

[BUG] dynamic `layout` does not work whithout remount

Open
#2,567 0 comments 5 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

1. Read the FAQs 👇
check

2. Describe the bug

(Not sure this is a bug or intended behavior, so please let me know if it is intended.)
If layout is changed to true after mount, motion.div does not animate.
In case layout is set to true on mount, it does animate as expected.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/framer-virtual-hgzcgz?file=%2Fsrc%2FApp.tsx%3A9%2C11

4. Steps to reproduce

  1. Click "Add" couple of times to add items with no layout prop set
  2. Click "Toggle" button to set layout to true for next items.
  3. Click "Add" again to more items.
  4. Items added in step 1 do not animate

5. Expected behavior
Items animate for layout changes even if layout prop is changed to true dynamically.

6. Video or screenshots

https://github.com/framer/motion/assets/99154189/75f3d441-160c-4e8c-9fb6-b05fc6787bd9

7. Environment details

If applicable, let us know which OS, browser, browser version etc you're using.

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

Begin with the linked CodeSandbox reproduction and verify the behavior described in the numbered steps. Then trace how motion.div handles a layout prop that changes after mount. Done means items animate layout changes both when layout is enabled initially and when it is enabled dynamically, with the reproduction no longer showing the bug.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.