Unstable exit positions under AnimatePresence popLayout with layout prop during simultaneous unmounts
0 reputation · 12 Feb 2022, 21:12 UTC
When several motion children wrapped in AnimatePresence use both the layout prop and mode="popLayout", the goal is to keep exiting items visually anchored while sibling items reflow. The documentation states that popLayout delays removal of exiting elements until layout measurements are captured, yet the exact ordering of layout capture, exit animation start, and DOM removal during simultaneous unmounts is not exhaustively specified.
Because Framer Motion major versions differ in layout measurement internals, the timing of these phases may not be identical across releases. Rapid successive unmounts can trigger reflows before exit animations begin, and reusing a layoutId on an exiting element and a newly mounted sibling introduces implementation-defined cross-fade pairing behavior.
What determines the precise sequence of layout measurement and DOM removal under popLayout when multiple children unmount at once? Does the layout prop change the point at which exiting elements leave the layout flow? How can layoutId collisions be avoided when concurrent exit and enter animations share the same identifier?