mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #816] [MERGED] fix: clear stale parallel slots on traversal in mergeElements #866
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#866
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/816
Author: @NathanDrake2406
Created: 4/10/2026
Status: ✅ Merged
Merged: 4/10/2026
Merged by: @james-elicx
Base:
main← Head:fix/traversal-stale-parallel-slots📝 Commits (5)
a7f6b93fix: clear stale parallel slots on traversal in mergeElementsb4c2b40refactor: collapse navigate/traverse reducer cases; add UNMATCHED_SLOT traversal testb26a410refactor: extract toActionType helper; add reducer-level traverse tests6d23e51fix cid996df4fix ci again📊 Changes
5 files changed (+137 additions, -7 deletions)
View changed files
📝
packages/vinext/src/server/app-browser-entry.ts(+12 -2)📝
packages/vinext/src/server/app-browser-state.ts(+5 -4)📝
packages/vinext/src/shims/slot.tsx(+17 -1)📝
tests/app-browser-entry.test.ts(+40 -0)📝
tests/slot.test.ts(+63 -0)📄 Description
Summary
"traverse"as a first-class action type in the router reducer, distinct from"navigate"and"replace"mergeElementsgains aclearAbsentSlotsflag (default false) that removes slot keys present inprevbut absent fromnextContext
When navigating back from an intercepted route (e.g.,
/feedwith photo modal -> browser back), the RSC response for the destination omits the@modalslot. Previously,mergeElementscarried the stale modal forward fromprevvia{ ...prev, ...next }.The fix cannot simply clear all absent slots because soft forward navigation (e.g.,
/dashboard->/dashboard/settings) intentionally omits parent layout slots that haven't changed. Those must be preserved.The solution: thread the navigation kind through the action type. Browser back/forward dispatches
"traverse"instead of"navigate", which tellsmergeElementsto clear absent slots.Closes #814
Test plan
mergeElements clears stale slots absent from next when clearAbsentSlots is setmergeElements preserves absent slots when clearAbsentSlots is not setmergeElementstests pass (UNMATCHED_SLOT preservation, shallow merge)parallel slot content persists on soft navigation to child route(existing, should still pass in CI)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.