Skip to content

Fix ViewTransition onExit cleanup timing on unmount#35950

Open
angular-bootstrap wants to merge 2 commits intofacebook:mainfrom
angular-bootstrap:viewtransition-onexit-cleanup-unmount
Open

Fix ViewTransition onExit cleanup timing on unmount#35950
angular-bootstrap wants to merge 2 commits intofacebook:mainfrom
angular-bootstrap:viewtransition-onexit-cleanup-unmount

Conversation

@angular-bootstrap
Copy link

Summary

Fixes a ViewTransition cleanup timing inconsistency for onExit.

Previously, onExit cleanup was attached to transition finish, so it could be delayed even when the transition subtree had already unmounted. This change marks onExit cleanup as unmount-bound and executes it immediately for that path, matching expected unmount cleanup behavior.

Changes

  • Extend pending view transition events to carry cleanup behavior metadata.
  • Add cleanupOnUnmount support to scheduleViewTransitionEvent.
  • Mark onExit scheduling with cleanupOnUnmount: true.
  • Execute cleanup immediately for unmount-bound events instead of waiting for transition finish.
  • Add regression coverage in ReactDOMViewTransition-test.

Test Plan

  • yarn test ReactDOMViewTransition-test --runInBand

Issue

Closes #35855

@meta-cla meta-cla bot added the CLA Signed label Mar 3, 2026
@react-sizebot
Copy link

Comparing: 4cc5b7a...5d7626b

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.05% 611.79 kB 612.10 kB +0.06% 108.12 kB 108.18 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.09% 677.72 kB 678.36 kB +0.10% 119.08 kB 119.19 kB
facebook-www/ReactDOM-prod.classic.js +0.04% 697.72 kB 698.03 kB +0.05% 122.59 kB 122.65 kB
facebook-www/ReactDOM-prod.modern.js +0.05% 688.03 kB 688.34 kB +0.05% 120.97 kB 121.03 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 5d7626b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: ViewTransition onExit cleanup not called on unmount

2 participants