Skip to content

Conversation

joseinaqa
Copy link
Contributor

@joseinaqa joseinaqa commented Oct 16, 2025

…p transition

Summary by CodeRabbit

  • New Features

    • View transition options can now be a function that returns transition type strings or false to skip the animation.
  • Improvements

    • Navigation can be more responsive when transitions are skipped.
    • Existing transition behavior remains when types are returned.
  • Documentation

    • Updated docs and examples describing the function signature, accepted return values, and short‑circuit behavior.

Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The router's view-transition types resolver now may return false. If it returns false, the view transition is short-circuited: the update runs immediately and startViewTransition is not invoked. The ViewTransitionOptions.types signature was widened accordingly.

Changes

Cohort / File(s) Summary
Router core change
packages/router-core/src/router.ts
- ViewTransitionOptions.types return type changed from () => Array<string> to () => Array<string> | false
- Added runtime guard: when resolver returns false, run the update callback immediately and skip calling startViewTransition
Navigate options docs
docs/router/framework/react/api/router/NavigateOptionsType.md
- Wording updated to clarify how viewTransition.types strings are derived/passed from navigate options
ViewTransitionOptions docs
docs/router/framework/react/api/router/ViewTransitionOptionsType.md
- Documented types as Array<string> or a function (locationChangeInfo) => Array<string> | false and described the false short-circuit and the locationChangeInfo shape

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant R as Router
  participant V as types resolver
  participant S as startViewTransition
  participant U as Update callback

  R->>V: resolved = types(locationChangeInfo)
  alt resolved === false
    note right of R#lightblue: Short-circuit (new)
    R->>U: run update immediately
    note right of R#lightblue: skip startViewTransition
  else resolved is string[]
    R->>S: startViewTransition(() => U())
    S-->>R: transition completes
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop across routes with a curious grin,
If false I spot, the curtain stays thin.
No flourish, no fade — the change comes through,
A tiny shortcut, swift and true. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix(router-core): return false to skip navigation using view transition types" directly and accurately describes the main change in the changeset. The core modification enables the types function within ViewTransitionOptions to return false (in addition to an array of strings), which short-circuits the view transition when this value is returned. The title is specific, concise, and uses the conventional "fix" prefix to indicate the change nature, making it immediately clear to team members reviewing the commit history what this PR accomplishes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 441f87d and a63cb1f.

📒 Files selected for processing (1)
  • docs/router/framework/react/api/router/ViewTransitionOptionsType.md (2 hunks)

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/router-core/src/router.ts (1)

2178-2181: LGTM! Short-circuit logic is correct.

The strict equality check and immediate execution correctly implement the skip behavior when the types resolver returns false. The implementation properly bypasses startViewTransition and executes the update function directly.

Consider adding a brief comment explaining the short-circuit behavior:

+        // Skip transition if types resolver returns false
         if (resolvedViewTransitionTypes === false) {
           fn()
           return
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4303a8a and ccc831f.

📒 Files selected for processing (1)
  • packages/router-core/src/router.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • packages/router-core/src/router.ts
packages/router-core/**

📄 CodeRabbit inference engine (AGENTS.md)

Keep framework-agnostic core router logic in packages/router-core/

Files:

  • packages/router-core/src/router.ts
🔇 Additional comments (1)
packages/router-core/src/router.ts (1)

768-778: LGTM! Type signature correctly reflects the new skip behavior.

The addition of false as a possible return type is backward compatible and clearly documents that the types function can now signal to skip the transition entirely.

@schiller-manuel
Copy link
Contributor

can you please update the docs?

Copy link

nx-cloud bot commented Oct 16, 2025

View your CI Pipeline Execution ↗ for commit fc8f773


☁️ Nx Cloud last updated this comment at 2025-10-16 18:19:12 UTC

@SeanCassiere SeanCassiere changed the title fix(core): allow default view transition types to return false to ski… fix(router-core): return false to skip navigation using view transition types Oct 16, 2025
@github-actions github-actions bot added the documentation Everything documentation related label Oct 16, 2025
@joseinaqa
Copy link
Contributor Author

can you please update the docs?

Sure! Done.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/router/framework/react/api/router/NavigateOptionsType.md (1)

47-56: Incomplete documentation of new false return capability.

Line 53 updates the description but doesn't explicitly mention that the types function can now return false to skip the view transition. The current wording only mentions that types "will determine the strings array," which omits the new short-circuit behavior.

Additionally, the sentence structure is convoluted with two separate conditions about browser support (starting with "If the browser does not support..."), making it unclear which fallback applies in which scenario. Consider restructuring this section to:

  1. Clearly state that types can return either an array of strings or false to skip the transition
  2. Separate the browser support fallback logic more clearly (distinguish between support for startViewTransition itself vs. support for types)

Suggested revision for line 53:

- If [`ViewTransitionOptions`](../ViewTransitionOptionsType.md), route navigations will be called using `document.startViewTransition({update, types})` where `types` will determine the strings array passed with `ViewTransitionOptions["types"]`. If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.
+ If [`ViewTransitionOptions`](../ViewTransitionOptionsType.md), the `types` option determines the strings array (or can return `false` to skip the transition entirely) passed to `document.startViewTransition({update, types})`. If the browser does not support the View Transitions API, this option is ignored and navigation proceeds normally.
🧹 Nitpick comments (1)
docs/router/framework/react/api/router/ViewTransitionOptionsType.md (1)

27-39: Minor formatting inconsistency and potential missing punctuation.

The documentation clearly explains the updated types property and its dual return capability. However, there are minor issues:

  1. Line 39 appears incomplete: The text ends with "or false to cancel the view transition" without a closing period. This should conclude the list item.

  2. Consistency: Consider whether the term "cancel" (used here) should align more closely with the terminology used elsewhere in the codebase. The PR description mentions "skip navigation" while this doc uses "cancel the view transition"—both are correct but subtle terminology differences could create confusion.

  3. Formatting: Lines 36 and 38 both reference document.startViewTransition({update, types}) call with identical wording. This is fine for clarity, but the nested bullet structure could be more visually distinct.

Consider closing line 39 with a period and optionally expanding the explanation slightly:

-    - or `false` to cancel the view transition
+    - or `false` to skip the view transition (the update will run immediately without starting a transition)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc8f773 and 441f87d.

📒 Files selected for processing (2)
  • docs/router/framework/react/api/router/NavigateOptionsType.md (1 hunks)
  • docs/router/framework/react/api/router/ViewTransitionOptionsType.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (AGENTS.md)

Use internal docs links relative to the docs/ folder (e.g., ./guide/data-loading)

Files:

  • docs/router/framework/react/api/router/ViewTransitionOptionsType.md
  • docs/router/framework/react/api/router/NavigateOptionsType.md
docs/{router,start}/**

📄 CodeRabbit inference engine (AGENTS.md)

Place router docs under docs/router/ and start framework docs under docs/start/

Files:

  • docs/router/framework/react/api/router/ViewTransitionOptionsType.md
  • docs/router/framework/react/api/router/NavigateOptionsType.md
🪛 LanguageTool
docs/router/framework/react/api/router/ViewTransitionOptionsType.md

[grammar] ~36-~36: There might be a mistake here.
Context: ...y of strings that will be passed to the document.startViewTransition({update, types}) call - A function that accepts `locationChangeI...

(QB_NEW_EN)


[grammar] ~37-~37: There might be a mistake here.
Context: ...onChangeInfo` object and returns either: - An array of strings that will be passed ...

(QB_NEW_EN)


[grammar] ~38-~38: There might be a mistake here.
Context: ...y of strings that will be passed to the document.startViewTransition({update, types}) call - or false to cancel the view transition...

(QB_NEW_EN)


[grammar] ~39-~39: There might be a mistake here.
Context: ...or false to cancel the view transition

(QB_NEW_EN)

docs/router/framework/react/api/router/NavigateOptionsType.md

[style] ~53-~53: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... with ViewTransitionOptions["types"]. If the browser does not support viewTransi...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[grammar] ~53-~53: Ensure spelling is correct
Context: ...pes"]`. If the browser does not support viewTransition types, the navigation will fall back to...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~53-~53: There might be a mistake here.
Context: ...k to normal document.startTransition(), same as if true was passed. - If the ...

(QB_NEW_EN)


[grammar] ~53-~53: There might be a mistake here.
Context: ...sition(), same as if true` was passed. - If the browser does not support this api...

(QB_NEW_EN)

@schiller-manuel schiller-manuel changed the title fix(router-core): return false to skip navigation using view transition types fix(router-core): allow to return false to skip navigation using view transition types Oct 17, 2025
@schiller-manuel schiller-manuel merged commit 7a55d7d into TanStack:main Oct 17, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Everything documentation related package: router-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants