Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Feb 2, 2026

fixes #6574

Summary by CodeRabbit

  • Bug Fixes

    • Improved parent route resolution logic to accurately locate the closest registered parent in route hierarchies, particularly for nested lazy and virtual routes with multiple path segments.
  • Tests

    • Added test coverage for lazy-loaded routes with multiple dynamic slug parameters and complex nested routing structures.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Replaces a targeted parent lookup optimization in the route generator with a full path-segment walk to locate the closest registered parent, fixing parent assignment for lazy routes with multiple slug parameters. Adds test files reproducing the multi-slug-params scenario to validate the fix.

Changes

Cohort / File(s) Summary
Core Parent Resolution Logic
packages/router-generator/src/generator.ts
Modified parent resolution to iterate up path segments by trimming at each slash and querying routeNodesByPath for each intermediate prefix, selecting the closest match and breaking once found. Removes prior optimization condition in favor of direct proximity checks. Handles cases with multiple path segments lacking intermediate routes.
Lazy Multi-Slug Test Case
packages/router-generator/tests/generator/lazy-multi-slug-params/routeTree.snapshot.ts, packages/router-generator/tests/generator/lazy-multi-slug-params/routes/__root.tsx, packages/router-generator/tests/generator/lazy-multi-slug-params/routes/sub/route.lazy.tsx, packages/router-generator/tests/generator/lazy-multi-slug-params/routes/sub/test.lazy.tsx, packages/router-generator/tests/generator/lazy-multi-slug-params/routes/sub/$a.$b.lazy.tsx
New test scenario files establishing a lazy-loaded route tree for paths /sub, /sub/test, and /sub/$a/$b with multi-slug parameters, including generated snapshot, root route, and lazy route definitions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

package: router-generator

Suggested reviewers

  • nlynzaad

Poem

🐰 A sluggy path once lost its way,
With parents unclear, come what may,
But now we walk the segments through,
Finding closest kin on cue,
Multi-slug routes hop in place! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing parent route lookup in the router generator to handle multiple slug parameters.
Linked Issues check ✅ Passed The PR fixes the parent route lookup logic for lazy-loaded routes with multiple slug fields, directly addressing the issue #6574 where such routes were not rendered in the outlet.
Out of Scope Changes check ✅ Passed All changes relate to fixing the parent route resolution logic and adding test fixtures to validate the fix; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-6574

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Feb 2, 2026

View your CI Pipeline Execution ↗ for commit 2a65cdf

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m 8s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 36s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-02 23:14:14 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6581

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6581

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6581

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6581

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6581

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6581

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6581

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6581

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6581

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6581

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6581

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6581

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6581

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6581

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6581

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6581

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6581

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6581

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6581

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6581

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6581

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6581

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6581

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6581

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6581

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6581

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6581

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6581

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6581

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6581

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6581

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6581

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6581

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6581

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6581

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6581

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6581

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6581

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6581

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6581

commit: 2a65cdf

@schiller-manuel schiller-manuel merged commit 041e984 into main Feb 2, 2026
4 of 8 checks passed
@schiller-manuel schiller-manuel deleted the fix-6574 branch February 2, 2026 23:27
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.

Wrong parent route when using multiple slug fields within lazy route

2 participants