Repository navigation
Conversation
When an Activity is hidden, passive effects are disconnected by walking the committed tree. If a fiber still carries a ChildDeletion flag from an earlier commit, detachAlternateSiblings clears the sibling pointers along parentFiber.alternate.child. If an earlier render cloned the parent but was interrupted before it began that fiber, alternate.child === parentFiber.child. The links being cut are then those of the live children, so later updates lose siblings: deleted DOM nodes stay on screen and a Suspense fallback can remain beside its content. Skip the detach when both fibers share the same child, since those are the current children and not the previous ones. Adds a test that fails without the change. Fixes react#38430 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #38430.
If an
<Activity>is hidden after a render that was interrupted, deleted DOM nodes can stay on screen, and a Suspensefallback can be left next to its content.
On hide,
recursivelyTraverseDisconnectPassiveEffectswalks the committed tree. A fiber that still has aChildDeletionflag from an earlier commit goes throughdetachAlternateSiblings, which cuts thesiblinglinks alongparentFiber.alternate.child. Suppose an earlier render cloned the parent and was interrupted before it began thatfiber. Then
alternate.child === parentFiber.child, so the links being cut belong to the live children, and laterupdates lose those siblings.
The fix skips the detach when both fibers point to the same child. In that case they are the current children, not the
previous ones.
How did you test this change?
Added
packages/react-reconciler/src/__tests__/ReactActivityInterruptedHide-test.js. It interrupts a render, hidesthe Activity, shows it again, and checks the rendered output.
The test passes in all four configs with the change. With only
ReactFiberCommitWork.jsreverted, it fails in allfour.
yarn prettiermade no changes, andyarn lincandyarn flow dom-nodeboth pass.I also checked a standalone page in headless Chrome and Firefox, using 19.3.1 and a canary build from
edae846a9, indevelopment and production. The bug shows in each run, and a control case stays correct. I did not run the full
yarn testor the www/xplat flow targets.