[PR #927] [MERGED] fix(router): ignore pre-root parallel slots for routed layouts #955

Closed
opened 2026-05-06 13:11:13 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/927
Author: @NathanDrake2406
Created: 4/28/2026
Status: Merged
Merged: 4/28/2026
Merged by: @james-elicx

Base: mainHead: nathan/pre-root-parallel-slot-ownership


📝 Commits (1)

  • 56e02ad fix(router): ignore pre-root parallel slots for routed layouts

📊 Changes

2 files changed (+58 additions, -4 deletions)

View changed files

📝 packages/vinext/src/routing/app-router.ts (+12 -4)
📝 tests/routing.test.ts (+46 -0)

📄 Description

Summary

  • Stop attaching parallel slots discovered above a route's first/root layout to that route's parallelSlots.
  • Add scanner coverage for app/@modal/default.tsx with the selected root layout at app/(group)/layout.tsx.
  • Preserve the valid case where the slot is inside the selected root layout subtree, such as app/(group)/@modal/default.tsx.

Root cause / Why

discoverInheritedParallelSlots initialized layoutIdx to -1 when app/layout.* was absent, but immediately clamped that value to 0 for appDir and every segment before the first actual layout. A slot above the selected root layout, such as app/@modal/default.tsx, was therefore recorded as owned by layoutIndex: 0 and injected into app/(group)/layout.tsx.

That diverges from Next.js multiple-root-layout semantics. Next.js documents that omitting app/layout.js lets subdirectory layouts become root layouts: multiple root layout docs. The server tree construction also notes that parallel route children cannot exist above the root layout: create-component-tree note.

The fix keeps the pre-layout sentinel while scanning and skips those slots once the route has a real layout. Layout-less scanner metadata is intentionally preserved here; scanner validation fixes are intentionally separate in another PR.

Verification

  • vp test run tests/routing.test.ts
  • vp check packages/vinext/src/routing/app-router.ts tests/routing.test.ts

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/927 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/28/2026 **Status:** ✅ Merged **Merged:** 4/28/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `nathan/pre-root-parallel-slot-ownership` --- ### 📝 Commits (1) - [`56e02ad`](https://github.com/cloudflare/vinext/commit/56e02ade8d44576757b6397720b95419aa35e965) fix(router): ignore pre-root parallel slots for routed layouts ### 📊 Changes **2 files changed** (+58 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/routing/app-router.ts` (+12 -4) 📝 `tests/routing.test.ts` (+46 -0) </details> ### 📄 Description ## Summary - Stop attaching parallel slots discovered above a route's first/root layout to that route's `parallelSlots`. - Add scanner coverage for `app/@modal/default.tsx` with the selected root layout at `app/(group)/layout.tsx`. - Preserve the valid case where the slot is inside the selected root layout subtree, such as `app/(group)/@modal/default.tsx`. ## Root cause / Why `discoverInheritedParallelSlots` initialized `layoutIdx` to `-1` when `app/layout.*` was absent, but immediately clamped that value to `0` for `appDir` and every segment before the first actual layout. A slot above the selected root layout, such as `app/@modal/default.tsx`, was therefore recorded as owned by `layoutIndex: 0` and injected into `app/(group)/layout.tsx`. That diverges from Next.js multiple-root-layout semantics. Next.js documents that omitting `app/layout.js` lets subdirectory layouts become root layouts: [multiple root layout docs](https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/docs/01-app/03-api-reference/03-file-conventions/layout.mdx#L140-L145). The server tree construction also notes that parallel route children cannot exist above the root layout: [create-component-tree note](https://github.com/vercel/next.js/blob/ae61573e062e900050b8e6b24626e450accc4570/packages/next/src/server/app-render/create-component-tree.tsx#L1273-L1290). The fix keeps the pre-layout sentinel while scanning and skips those slots once the route has a real layout. Layout-less scanner metadata is intentionally preserved here; scanner validation fixes are intentionally separate in another PR. ## Verification - `vp test run tests/routing.test.ts` - `vp check packages/vinext/src/routing/app-router.ts tests/routing.test.ts` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:13 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#955
No description provided.