Skip to content

[DOM] Stop hiding siblings after a dehydrated Activity - #37814

Merged
eps1lon merged 2 commits into
react:mainfrom
skrabe:fix-hide-dehydrated-activity
Oct 12, 2026
Merged

eps1lon merged 2 commits into
react:mainfrom
skrabe:fix-hide-dehydrated-activity

Conversation

@skrabe

@skrabe skrabe commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #37813.

Summary

hideOrUnhideDehydratedBoundary accepts an Activity instance but only recognizes Suspense markers. Hiding a dehydrated Activity walked past its <!--/&--> and set display: none on every following sibling in the parent, outside the hidden tree. Those siblings stayed hidden after the Activity was shown again.

The walk now ends at <!--/&--> and counts <!--&--> for depth, matching clearHydrationBoundary.

How did you test this change?

The first commit adds a test to ReactDOMServerPartialHydrationActivity-test that pins down the current behavior: an Activity containing a dehydrated Activity (with a nested Activity inside it) is hidden, and the sibling after it ends up hidden too, and stays hidden after the Activity is shown again. It passes on main.

The second commit is the fix, and flips the sibling assertions. With only the end-marker half of the fix, the test fails on the content after the nested Activity, so the depth counting is covered too.

Ran:

  • yarn test and yarn test --prod for ReactDOMServerPartialHydration*, ReactDOMActivity* and ReactDOMFizzSuspenseList: all pass, at both commits for the new test.
  • yarn test -r=stable (dev and prod) for the new test, and -r=stable for ReactDOMServerPartialHydration*: all pass.
  • yarn flow dom-node, yarn flow dom-browser, yarn linc, yarn prettier: clean.

@meta-cla meta-cla Bot added the CLA Signed label Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Comparing: b618bbb...2191fb6

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 = 7.35 kB 7.35 kB -0.10% 1.96 kB 1.96 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.01% 626.03 kB 626.10 kB = 110.63 kB 110.63 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 7.36 kB 7.36 kB -0.10% 1.97 kB 1.96 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.01% 697.24 kB 697.31 kB = 122.06 kB 122.07 kB
facebook-www/ReactDOM-prod.classic.js +0.01% 715.27 kB 715.35 kB = 125.14 kB 125.14 kB
facebook-www/ReactDOM-prod.modern.js +0.01% 705.59 kB 705.66 kB = 123.56 kB 123.57 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by sizebot against 2191fb6

@eps1lon

eps1lon commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Can you split the commit into one commit with just a characterizing test and a second commit with the fix + changed assertions. The test must pass in both commits. it.failing is too coarse.

@skrabe
skrabe force-pushed the fix-hide-dehydrated-activity branch from 2c1097c to e7fe5a7 Compare October 12, 2026 08:50
@skrabe
skrabe force-pushed the fix-hide-dehydrated-activity branch from e7fe5a7 to e40e459 Compare October 12, 2026 09:23
@skrabe
skrabe requested a review from eps1lon October 12, 2026 09:30
…r siblings

When a dehydrated boundary is hidden, `hideOrUnhideDehydratedBoundary`
walks the DOM nodes from the boundary's start marker and sets
`display: none` on each element until it reaches the matching end marker.
The walk only recognizes Suspense markers: it stops at `<!--/$-->` and
counts only Suspense start markers for depth. For an Activity instance it
never sees the boundary's `<!--/&-->`, so it continues to the end of the
parent and hides every following sibling, nodes that are not part of the
hidden tree.

Showing the Activity again does not undo this. Its dehydrated content is
client rendered, and nothing unhides the siblings, so they stay hidden.

Next.js keeps a route it navigates away from in a hidden Activity. Leaving
a page before its boundaries hydrated hides what the root layout renders
after the page, such as toasts and the route announcer.

The test pins down the current behavior. The fix in the next commit flips
the sibling assertions: it stays visible while the Activity is hidden and
after it is shown again.
`hideOrUnhideDehydratedBoundary` accepts an Activity instance but only
recognized Suspense markers, so hiding a dehydrated Activity walked past
its end marker and hid every following sibling in the parent.

The walk now treats `<!--/&-->` as an end marker and counts `<!--&-->`
for depth, as `clearHydrationBoundary` already does. Both are needed:
with only the end marker, a nested Activity's `<!--/&-->` ends the walk
early and leaves the rest of the boundary visible.

The test from the previous commit flips its sibling assertions: the
sibling stays visible while the Activity is hidden and after it is shown
again. The test is renamed to match.
@skrabe
skrabe force-pushed the fix-hide-dehydrated-activity branch from e40e459 to 2191fb6 Compare October 12, 2026 10:51
@skrabe
skrabe requested a review from eps1lon October 12, 2026 10:57

@eps1lon eps1lon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@eps1lon
eps1lon merged commit 9f2e1f8 into react:main Oct 12, 2026
239 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
Fixes #37813.

## Summary

`hideOrUnhideDehydratedBoundary` accepts an Activity instance but only
recognizes Suspense markers. Hiding a dehydrated Activity walked past
its `<!--/&-->` and set `display: none` on every following sibling in
the parent, outside the hidden tree. Those siblings stayed hidden after
the Activity was shown again.

The walk now ends at `<!--/&-->` and counts `<!--&-->` for depth,
matching `clearHydrationBoundary`.

## How did you test this change?

The first commit adds a test to
`ReactDOMServerPartialHydrationActivity-test` that pins down the current
behavior: an Activity containing a dehydrated Activity (with a nested
Activity inside it) is hidden, and the sibling after it ends up hidden
too, and stays hidden after the Activity is shown again. It passes on
`main`.

The second commit is the fix, and flips the sibling assertions. With
only the end-marker half of the fix, the test fails on the content after
the nested Activity, so the depth counting is covered too.

Ran:

- `yarn test` and `yarn test --prod` for
`ReactDOMServerPartialHydration*`, `ReactDOMActivity*` and
`ReactDOMFizzSuspenseList`: all pass, at both commits for the new test.
- `yarn test -r=stable` (dev and prod) for the new test, and `-r=stable`
for `ReactDOMServerPartialHydration*`: all pass.
- `yarn flow dom-node`, `yarn flow dom-browser`, `yarn linc`, `yarn
prettier`: clean.

DiffTrain build for [9f2e1f8](9f2e1f8)
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
Fixes #37813.

## Summary

`hideOrUnhideDehydratedBoundary` accepts an Activity instance but only
recognizes Suspense markers. Hiding a dehydrated Activity walked past
its `<!--/&-->` and set `display: none` on every following sibling in
the parent, outside the hidden tree. Those siblings stayed hidden after
the Activity was shown again.

The walk now ends at `<!--/&-->` and counts `<!--&-->` for depth,
matching `clearHydrationBoundary`.

## How did you test this change?

The first commit adds a test to
`ReactDOMServerPartialHydrationActivity-test` that pins down the current
behavior: an Activity containing a dehydrated Activity (with a nested
Activity inside it) is hidden, and the sibling after it ends up hidden
too, and stays hidden after the Activity is shown again. It passes on
`main`.

The second commit is the fix, and flips the sibling assertions. With
only the end-marker half of the fix, the test fails on the content after
the nested Activity, so the depth counting is covered too.

Ran:

- `yarn test` and `yarn test --prod` for
`ReactDOMServerPartialHydration*`, `ReactDOMActivity*` and
`ReactDOMFizzSuspenseList`: all pass, at both commits for the new test.
- `yarn test -r=stable` (dev and prod) for the new test, and `-r=stable`
for `ReactDOMServerPartialHydration*`: all pass.
- `yarn flow dom-node`, `yarn flow dom-browser`, `yarn linc`, `yarn
prettier`: clean.

DiffTrain build for [9f2e1f8](9f2e1f8)
eps1lon added a commit to vercel/next.js that referenced this pull request Oct 14, 2026
[diff
react/react@b618bbb4...07dde64d](react/react@b618bbb...07dde64)

<details>
<summary>React upstream changes</summary>

- react/react#37710
- react/react#37814
- react/react#37778
- react/react#37688
- react/react#37796

</details>

---------

Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Sebbie Silbermann <[email protected]>
stefanprobst added a commit to acdh-oeaw/template-app-next that referenced this pull request Nov 21, 2026
With `cacheComponents`, Next.js wraps each page in an `<Activity>`. When a
client navigation hides a page that has not hydrated yet, React hides its
server-rendered nodes by walking their siblings until the end of the boundary,
but only recognizes Suspense markers, not Activity markers. It then also hides
the layout content after the page, like the footer, and never shows it again.
This failed the shell end-to-end tests in WebKit intermittently.

The fix (react/react#37814) is in the React that `16.5.0-canary.59`
bundles, but not in `16.4.6`, so our Next.js patch applies it to the bundled
React builds until then.
SiddharthMuramkar added a commit to SiddharthMuramkar/friends-of-animals that referenced this pull request Nov 22, 2026
Main's #239 fences the @EXIT slot the same way this branch did, for the
same React bug (react/react#37814); the layout now takes main's version
and comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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: Hiding a dehydrated Activity hides every sibling after it

2 participants