Skip to content

fix(transition-group): avoid repeating outer move in nested groups - #15660

Closed
balwahidi wants to merge 1 commit into
vuejs:mainfrom
balwahidi:fix/nested-transition-group-move
Closed

balwahidi wants to merge 1 commit into
vuejs:mainfrom
balwahidi:fix/nested-transition-group-move

Conversation

@balwahidi

@balwahidi balwahidi commented Sep 26, 2026 •

Copy link
Copy Markdown

close #5385
close #1531

Problem

When a <TransitionGroup> is nested inside an item of another <TransitionGroup> and the outer list reorders, the inner items get the outer movement applied twice:

Fix

If a group has an ancestor <TransitionGroup>, it now measures its children relative to the outer group's item that contains it. The outer group still animates that item, including everything inside it, and the inner group only animates movement within the item. Groups that aren't nested are unchanged.

Why not measure relative to the parent element (as in #8803)?

I tried that first. It fixes the nested case but breaks groups whose container moves itself. For example, in a bottom-anchored toast stack (position: fixed; bottom: 0), adding a toast moves the existing toasts up on screen but not relative to their container, so they jump instead of sliding. With this PR they still animate.

Verification

  • New e2e test. It swaps the outer items and reorders one inner list:
    • On main it fails: items that only rode along get inner-move.
    • With the fix it passes: only items that really moved within their outer item get inner-move.
  • All Transition/TransitionGroup browser e2e tests pass, as does the full unit suite.
  • Checked in Chromium, sampling positions 100–200 ms into the move:
    • inconsistent behaviour on nested transition groups #1531's own vue3.html: 6/6 inner items fly sideways on main, 0/6 with this PR.
    • Also checked: an outer group without tag, an inner group that is itself the outer item, an inner group without tag, and 3 levels of nesting.
    • Flat lists and a bottom-anchored stack animate as before.

Thanks to @daniser for the earlier attempt in #8803.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Corrected movement tracking in nested transition groups, so animations are measured relative to the containing item. Nested items now move smoothly when groups are reordered.

close vuejs#5385
close vuejs#1531

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e83573af-7718-4b2c-a69d-032c875727cc

📥 Commits

Reviewing files that changed from the base of the PR and between 4ab865a and 24199d3.

📒 Files selected for processing (2)
  • packages/runtime-dom/src/components/TransitionGroup.ts
  • packages/vue/__tests__/e2e/TransitionGroup.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

TransitionGroup now measures nested children relative to the nearest ancestor group’s rendered item when available. An end-to-end test checks move classes when outer groups and inner items reorder.

Changes

Nested Group Positioning

Layer / File(s) Summary
Ancestor-relative position measurement and test
packages/runtime-dom/src/components/TransitionGroup.ts, packages/vue/__tests__/e2e/TransitionGroup.spec.ts
TransitionGroup finds the nearest ancestor TransitionGroup and uses its rendered item as the origin for child position measurements. The end-to-end test checks outer and inner move classes during nested reordering.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 24199

The nested-group positioning change is ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 24199

The change affects browser animation positioning. The reviewed path does not introduce access to privileges, sensitive data, or another service. Risk remains low rather than minimal because coverage of the broader change is incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The examined effect is bounded to rendered TransitionGroup items and their CSS movement in a consuming page; the reviewed path does not lead to a privileged or cross-service sink.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing repeated outer movement in nested TransitionGroup instances.
Linked Issues check ✅ Passed The PR implements the linked objectives [#5385] and [#1531]. TransitionGroup finds the nearest ancestor group and records nested positions relative to the containing outer item. This prevents repeat…
Out of Scope Changes check ✅ Passed The reviewed changes are limited to packages/runtime-dom/src/components/TransitionGroup.ts and its end-to-end test. The source change implements nested-group position measurement. The test directly …
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edison1105

Copy link
Copy Markdown
Member

Thanks for working on this! Measuring relative to the enclosing item can suppress valid inner moves when the outer group has no move transition or doesn't update.

I've opened #15848 to account for which enclosing groups actually handle the movement and keep the origin and child measurements aligned, with additional coverage for deeper nesting and different update orders. Closing this in favor of that PR.

@edison1105 edison1105 closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary move animation in nested <transition-group> inconsistent behaviour on nested transition groups

2 participants