[PR #781] [MERGED] fix: populate parallel route segments in LayoutSegmentProvider #843

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

📋 Pull Request Information

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

Base: mainHead: fix/parallel-route-segment-map


📝 Commits (1)

  • 499b4a6 fix: populate parallel route segments in LayoutSegmentProvider

📊 Changes

4 files changed (+93 additions, -28 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+1 -0)
📝 packages/vinext/src/routing/app-router.ts (+31 -10)
📝 packages/vinext/src/server/app-page-route-wiring.tsx (+35 -13)
📝 tests/app-router.test.ts (+26 -5)

📄 Description

Summary

  • useSelectedLayoutSegment(key) always returned null for named parallel route keys (e.g., @modal, @sidebar) because the LayoutSegmentProvider's segmentMap only ever contained the "children" key
  • Added routeSegments field to ParallelSlot — populated at scan time with the filesystem segments from the slot root to its active page ([] for root page, ["members"] for sub-pages, null for default fallback)
  • The segment map now includes per-slot entries at each layout level, so useSelectedLayoutSegment("team") correctly returns the active segment when @team/members/page.tsx is matched

Test plan

  • Existing useSelectedLayoutSegments() (children key) tests still pass
  • New test: useSelectedLayoutSegments("team") returns ["members"] on /dashboard/members
  • New test: useSelectedLayoutSegments("analytics") returns [] when slot shows default.tsx
  • All 287 app-router tests pass
  • All 91 routing scanner tests pass
  • pnpm run check passes (no new type errors or lint issues)

🔄 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/781 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/4/2026 **Status:** ✅ Merged **Merged:** 4/4/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/parallel-route-segment-map` --- ### 📝 Commits (1) - [`499b4a6`](https://github.com/cloudflare/vinext/commit/499b4a6016a01375ef39e332137c372281d37da2) fix: populate parallel route segments in LayoutSegmentProvider ### 📊 Changes **4 files changed** (+93 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+1 -0) 📝 `packages/vinext/src/routing/app-router.ts` (+31 -10) 📝 `packages/vinext/src/server/app-page-route-wiring.tsx` (+35 -13) 📝 `tests/app-router.test.ts` (+26 -5) </details> ### 📄 Description ## Summary - `useSelectedLayoutSegment(key)` always returned `null` for named parallel route keys (e.g., `@modal`, `@sidebar`) because the `LayoutSegmentProvider`'s `segmentMap` only ever contained the `"children"` key - Added `routeSegments` field to `ParallelSlot` — populated at scan time with the filesystem segments from the slot root to its active page (`[]` for root page, `["members"]` for sub-pages, `null` for default fallback) - The segment map now includes per-slot entries at each layout level, so `useSelectedLayoutSegment("team")` correctly returns the active segment when `@team/members/page.tsx` is matched ## Test plan - [x] Existing `useSelectedLayoutSegments()` (children key) tests still pass - [x] New test: `useSelectedLayoutSegments("team")` returns `["members"]` on `/dashboard/members` - [x] New test: `useSelectedLayoutSegments("analytics")` returns `[]` when slot shows `default.tsx` - [x] All 287 app-router tests pass - [x] All 91 routing scanner tests pass - [x] `pnpm run check` passes (no new type errors or lint issues) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:25 +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#843
No description provided.