Skip to content

fix(router-generator): keep dotted pathless layout filenames as one segment#7771

Open
thribhuvan003 wants to merge 1 commit into
TanStack:mainfrom
thribhuvan003:fix/virtual-pathless-layout-dotted-filename
Open

fix(router-generator): keep dotted pathless layout filenames as one segment#7771
thribhuvan003 wants to merge 1 commit into
TanStack:mainfrom
thribhuvan003:fix/virtual-pathless-layout-dotted-filename

Conversation

@thribhuvan003

@thribhuvan003 thribhuvan003 commented Jul 10, 2026

Copy link
Copy Markdown

virtual layout() with a dotted filename like pathless.layout.tsx was turning the layout id into /_pathless/layout, so kids got mounted under a real /layout URL segment instead of staying at /subpath. dots in layout ids are part of the filename, not path separators - escape them before determineInitialRoutePath so the id stays one pathless segment. generator fixture covers it (fullPaths stays / and /subpath).

Fixes #7761.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed route generation for virtual pathless layouts with dotted filenames.
    • Dots in layout filenames are now preserved as part of the layout name instead of creating unintended URL path segments.
    • Child routes now retain their intended paths when nested under these layouts.
  • Tests

    • Added coverage for dotted virtual pathless layout filenames and nested child routes.

…egment

layout('pathless.layout.tsx') was splitting the layout id on dots via determineInitialRoutePath, so children mounted under a leaked /layout URL segment. Escape unbracketed dots in virtual layout ids so the pathless segment stays intact.

Fixes TanStack#7761.
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91795793-468b-4341-ab2c-51a2625c0ebc

📥 Commits

Reviewing files that changed from the base of the PR and between a3e24c3 and 2c215e1.

📒 Files selected for processing (8)
  • .changeset/virtual-pathless-layout-dotted-filename.md
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routes/index.route.tsx
  • packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routes/pathless.layout.tsx
  • packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routes/root.route.tsx
  • packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routes/subpath.route.tsx

📝 Walkthrough

Walkthrough

Updates virtual route generation so dotted pathless layout IDs remain single segments, and adds a regression fixture with generated route-tree coverage plus a patch changeset.

Changes

Virtual pathless layout path handling

Layer / File(s) Summary
Escape dotted layout IDs
packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
Layout IDs now escape unbracketed dots before initial route path determination.
Validate generated dotted layout routes
packages/router-generator/tests/generator.test.ts, packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/*, .changeset/virtual-pathless-layout-dotted-filename.md
Adds a virtual route configuration, root/layout/index/subpath fixtures, generated route-tree wiring and types, and a patch changeset for dotted pathless layouts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: package: router-generator

Suggested reviewers: schiller-manuel, nlynzaad

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the dotted pathless layout filename fix in router-generator.
Linked Issues check ✅ Passed The fix escapes dotted layout IDs and the new fixture verifies children stay reachable at /subpath, matching #7761.
Out of Scope Changes check ✅ Passed The changes stay focused on the router-generator bug fix, related test coverage, and release note entry.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

virtualRouteConfig regression: pathless layout() with a dotted filename splits the dot into a new path segment

1 participant