Skip to content

fix(react-router): keep relative link active when changing inherited param#6689

Open
Sheraff wants to merge 2 commits intomainfrom
codex/issue-5655-repro
Open

fix(react-router): keep relative link active when changing inherited param#6689
Sheraff wants to merge 2 commits intomainfrom
codex/issue-5655-repro

Conversation

@Sheraff
Copy link
Contributor

@Sheraff Sheraff commented Feb 17, 2026

Summary

Testing

  • skipped per request

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Fixed an issue where relative links would not maintain their active state when inherited route parameters changed. Links now correctly reflect their active status when navigating between routes with dynamic parameters, ensuring accurate visual feedback in complex, multi-level routing scenarios with parameter inheritance.

@Sheraff Sheraff changed the title fix(react-router): keep relative link active when changind inherited param fix(react-router): keep relative link active when changing inherited param Feb 17, 2026
@nx-cloud
Copy link

nx-cloud bot commented Feb 17, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 52239e9

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

☁️ Nx Cloud last updated this comment at 2026-02-17 23:57:33 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 17, 2026

More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 52239e9

@Sheraff Sheraff marked this pull request as draft February 17, 2026 22:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

The useLinkProps hook now subscribes to a selector returning href and leafParams instead of just location.search, expanding reactivity to inherited param changes. An internal variable is renamed from currentSearch to currentLocationState. A test verifies active state maintenance when inherited params change.

Changes

Cohort / File(s) Summary
Link Component Reactivity
packages/react-router/src/link.tsx
Modified useLinkProps hook to subscribe to a selector returning href and leafParams instead of location.search. Renamed currentSearch variable to currentLocationState to reflect broader state tracking and dependency updates.
Test Coverage
packages/react-router/tests/link.test.tsx
Added comprehensive test case verifying that relative links maintain active state when inherited route params change across multi-level routes (issue #5655).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • schiller-manuel

Poem

🐰 A selector so keen, observing leafParams dance,
Links now wake to inherited change's romance,
Active states whisper through nested route halls,
When postId shifts, relative navigation calls,
Hopping through hierarchies, staying true and bright! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing relative link active states when inherited params change, which aligns with the implementation fix in useLinkProps and the regression test added.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 codex/issue-5655-repro

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

@Sheraff Sheraff marked this pull request as ready for review February 17, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant