fix(app-router): keep shared layouts out of ancestor loading entries by umeraamir69 · Pull Request #4132 · cloudflare/vinext · GitHub
Skip to content

fix(app-router): keep shared layouts out of ancestor loading entries - #4132

Open
umeraamir69 wants to merge 3 commits into
cloudflare:mainfrom
umeraamir69:fix/link-soft-navigation
Open

umeraamir69 wants to merge 3 commits into
cloudflare:mainfrom
umeraamir69:fix/link-soft-navigation

Conversation

@umeraamir69

Copy link
Copy Markdown

Summary

  • Soft <Link> moves under an ancestor loading.tsx were remounting a shared layout that should stay mounted. #2940 already refused the optimistic loading shell; the leftover remount was the real RSC payload wrapping that layout's own Flight entry in the ancestor Suspense.
  • Real navigations now leave ancestor loading on the route-entry per-segment boundary (first paint still works). Loading-shell prefetches still attach the fallback to layout entries, because those shells skip the per-segment wrappers.
  • Same-slug child, nested dynamic, back, and parallel-slot moves keep the [slug] layout identity. Changing the slug still mints a new identity.

Fixes #1523

This does not replace #3788. That PR rewrites where ancestor loading is placed and how it is keyed. This change only stops the layout Flight record from carrying that Suspense on a real navigation, which is what discarded the layout-identity DOM node.

Test plan

  • vp test run --project unit tests/app-page-route-wiring.test.ts tests/app-optimistic-routing.test.ts tests/navigation-planner.test.ts (158 passed)
  • tests/e2e/cloudflare-workers/layout-identity.spec.ts on the app-router-cloudflare Worker (existing fixture: parent, child, item, back, parallel slot, client state)
  • Confirm a first visit into a tree with ancestor loading.tsx still shows the fallback while a slow child layout resolves
  • Confirm navigating to a different [slug] value still remounts that layout

An ancestor loading.tsx was wrapping the shared layout Flight record on
every real navigation, so same-slug Link moves remounted a layout that
should stay mounted. Leave that Suspense on the route entry instead.
@umeraamir69

Copy link
Copy Markdown
Author

@clanky-the-clanker

Copy link
Copy Markdown

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.

App Router: client <Link> soft navigation triggers full server re-render

1 participant