Skip to content

TanStack: Keep Start's document shell out of stories - #35504

Merged
huang-julien merged 2 commits into
storybookjs:nextfrom
unpunnyfuns:fix/tanstack-react-root-shell-component
Jul 17, 2026
Merged

huang-julien merged 2 commits into
storybookjs:nextfrom
unpunnyfuns:fix/tanstack-react-root-shell-component

Conversation

@unpunnyfuns

@unpunnyfuns unpunnyfuns commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Follows #35501

What I did

A TanStack Start root route's shellComponent renders the document (html/head/body) inside the story canvas. React logs an invalid-nesting error for each document element, warns about hydration mismatches, and hoists the shell's head content into the real page.

Rendering a story changes the document title and injects the app's meta tags into the Storybook page.

duplicateRouteTree now strips shellComponent from the copied root options. All other root behavior keeps working in stories: the root layout component, notFoundComponent, errorComponent, and beforeLoad context.

Similar implementations

#35217 identified this problem first and fixes it by not copying any root options. We ran both approaches against our
story-level conformance suite.

Dropping every root option also removes the root notFoundComponent, error handling, and context that existing stories rely on, and those stories fail.

Stripping only the shell fixes the document leak with no other behavior change, which is why this PR proposes the narrower version.

Manual testing

  • yarn vitest run code/frameworks/tanstack-react (55 tests).
  • End to end: the NoDocumentShellInStories stories fail without it, with document title
    hijacked by the story.

AI disclosure

Root-cause analysis, fix, and tests developed with Claude (Claude Code), reviewed and submitted by me.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed duplicated route trees to preserve root-level components and loading behavior.
    • Prevented shell components from being incorrectly carried over to cloned root routes.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor
Fails
🚫 PR description is missing the mandatory "#### Manual testing" section. Please add it so that reviewers know how to manually test your changes.

Generated by 🚫 dangerJS against c9938fa

@unpunnyfuns unpunnyfuns changed the title Tanstack-React: Keep Start's document shell out of stories Tanstack: Keep Start's document shell out of stories Jul 16, 2026
@unpunnyfuns unpunnyfuns changed the title Tanstack: Keep Start's document shell out of stories TanStack: Keep Start's document shell out of stories Jul 16, 2026
@unpunnyfuns
unpunnyfuns marked this pull request as ready for review July 16, 2026 16:36
@coderabbitai

coderabbitai Bot commented Jul 16, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc91271b-859a-4bf6-b7a6-ce1af9e6c735

📥 Commits

Reviewing files that changed from the base of the PR and between c0cf10e and c9938fa.

📒 Files selected for processing (2)
  • code/frameworks/tanstack-react/src/routing/duplicate-tree.test.ts
  • code/frameworks/tanstack-react/src/routing/duplicate-tree.ts

📝 Walkthrough

Walkthrough

duplicateRouteTree now removes shellComponent when cloning the root route while preserving other root options. Tests verify that component and beforeLoad remain available and shellComponent is undefined.

Changes

Root route cloning

Layer / File(s) Summary
Root option filtering and validation
code/frameworks/tanstack-react/src/routing/duplicate-tree.ts, code/frameworks/tanstack-react/src/routing/duplicate-tree.test.ts
Cloned root routes omit shellComponent while retaining component and beforeLoad; tests cover the updated behavior and import vi from Vitest.

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

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@huang-julien huang-julien added bug ci:normal Run our default set of CI jobs (choose this for most PRs). tanstack qa:skip Pull Requests that do not need any QA. (e.g. documentation) labels Jul 17, 2026
@huang-julien
huang-julien enabled auto-merge July 17, 2026 12:43
@huang-julien
huang-julien merged commit 9e0b558 into storybookjs:next Jul 17, 2026
135 of 140 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
2 tasks done
@unpunnyfuns
unpunnyfuns deleted the fix/tanstack-react-root-shell-component branch July 17, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-scan:human bug ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation) tanstack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants