Skip to content

fix(react-router): respect explicit undefined stylesheet precedence - #8823

Open
benjavicente wants to merge 1 commit into
TanStack:mainfrom
benjavicente:fix/stylesheet-precedence-override
Open

benjavicente wants to merge 1 commit into
TanStack:mainfrom
benjavicente:fix/stylesheet-precedence-override

Conversation

@benjavicente

@benjavicente benjavicente commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

🎯 Changes

Allow precedence: undefined in React Router head links to opt out of React stylesheet hoisting. Set the default before spreading link attributes, preserving explicit string precedence and the protected nonce/hydration-warning props.

Adds regressions for absent, undefined, and string precedence, plus SSR ordering with a classic inline theme script before an opted-out stylesheet. Generated Start manifest CSS defaults are unchanged.

Validation: 38 focused unit tests, TypeScript matrix, ESLint, 3 Start SSR Chromium tests, and the SSR head workload pass. The full 18-scenario bundle comparison has no gzip growth.

AI-assisted implementation and tests using Codex.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features
    • Stylesheet links now support opting out of React’s stylesheet hoisting by explicitly setting precedence to undefined. When precedence is omitted, the default behavior remains unchanged, and explicitly provided string values are preserved.
    • Opted-out route stylesheets render after classic inline theme scripts and without a precedence attribute.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0f043f4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tanstack/react-router Patch
@tanstack/react-start-client Patch
@tanstack/react-start-rsc Patch
@tanstack/react-start-server Patch
@tanstack/react-start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between da2adec and 0f043f4.

Files selected for processing: 3
  • .changeset/puny-chicken-clap.md
  • packages/react-router/src/Asset.tsx
  • packages/react-router/tests/Asset.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Stylesheet links now default to "default" precedence when precedence is omitted. An explicit undefined opts out of precedence, and an explicit string is preserved. SSR tests cover these cases and check stylesheet ordering after an inline theme script.

Changes: Stylesheet precedence

Layer / File(s) Summary
Set and verify stylesheet precedence
packages/react-router/src/Asset.tsx, packages/react-router/tests/Asset.test.tsx, .changeset/puny-chicken-clap.md
Asset sets precedence based on the link relation. SSR tests cover omitted, undefined, and explicit precedence values, and check the opted-out stylesheet appears after an inline script. The changeset documents the behavior.

Priority: Low

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

Change: Bug fix

Suggested reviewers: schiller-manuel

Merge Risk: Minimal · up to 0f043

The stylesheet precedence change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: respecting an explicit undefined stylesheet precedence in React Router.
Description check Passed The description explains the change, motivation, tests, AI assistance, checklist status, and release impact. The only incomplete item is the unchecked statement that the author fully understands the c…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the change, motivation, tests, AI assistance, checklist status, and release impact. The only incomplete item is the unchecked statement that the author fully understands the code, but the description is otherwise complete and directly related to the changes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nx-cloud

nx-cloud Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 0f043f4

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

☁️ Nx Cloud last updated this comment at 2026-10-27 21:12:55 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8823

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8823

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8823

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8823

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8823

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8823

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8823

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8823

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8823

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8823

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8823

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8823

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8823

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8823

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8823

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8823

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8823

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8823

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8823

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8823

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8823

commit: 0f043f4

@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 5.03%

2 warnings, 1 note

⚠️ 43 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

ℹ️ 3 benchmarks have no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 3 improved benchmarks
✅ 191 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Memory mem client interrupted-navigations (vue) 99.8 KB 94 KB +6.11%
⚡ Memory mem client navigation-churn (solid) 109.7 KB 103.5 KB +5.99%
⚡ Memory mem client unique-location-churn (vue) 82.8 KB 80.3 KB +3.03%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing benjavicente:fix/stylesheet-precedence-override (0f043f4) with main (da2adec)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

This branch has not been deployed

No deployments
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.

1 participant