Skip to content

Shared layout animation uses stale snapshot when clicking items rapidly (wrong card origin during open/close animation) #3424

@MaxVhanamane

Description

@MaxVhanamane

Description:

I’m using layoutId to animate cards into a fullscreen view.

When interacting at normal speed, everything works correctly:

Opening animates from the clicked card → fullscreen

Closing animates fullscreen → back to the correct card position

The animation always uses the correct origin and destination

However, when clicking different cards very quickly, the shared layout animation becomes incorrect:

The first click always opens from the correct card

But on rapid subsequent clicks:

The fullscreen animation may open from the wrong card position

Or closing may animate back to a card that was clicked several interactions earlier

The wrong origin is not always the immediately previous card ... sometimes it’s 2–3 cards earlier

This only happens during fast interactions.
At normal clicking speed, the animations behave correctly.

It seems like motion/react is using a stale layout snapshot when rapid state changes occur, causing shared layout transitions to pair with the wrong element.

what is going on here?

Expected behavior

Shared layout transitions should always animate from and back to the correct element, regardless of interaction speed.

animation-issue.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions