Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix: only set Link aria-current on exact pathname matches - #8994

Open
YehudaMenahem wants to merge 1 commit into
TanStack:mainfrom
YehudaMenahem:cursor/fix-aria-current-exact-0ed6
Open

YehudaMenahem wants to merge 1 commit into
TanStack:mainfrom
YehudaMenahem:cursor/fix-aria-current-exact-0ed6

Conversation

@YehudaMenahem

@YehudaMenahem YehudaMenahem commented Nov 27, 2026 •

Copy link
Copy Markdown

🎯 Changes

Fixes #8979.

Fuzzy/ancestor Links remain visually active (isActive, activeProps, data-status), but aria-current="page" is only set when the link pathname matches the current location exactly. That matches ARIA guidance that only one element in a set should be marked current.

Docs note this under Active Options. Includes a changeset.

✅ 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

  • Bug Fixes
    • Updated React, Solid, and Vue links so aria-current="page" is set only on links whose pathname exactly matches the current page. Fuzzy ancestor links remain active for styling.
  • Documentation
    • Clarified how active styling and aria-current behave for exact and fuzzy link matches.

Fuzzy/ancestor Links stay visually active for styling, but
aria-current="page" is reserved for the exact current path so
hierarchical nav no longer announces multiple current pages.

Closes TanStack#8979

Co-authored-by: Yehuda Menahem <jmenahem@gmail.com>
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad960fb

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

This PR includes changesets to release 13 packages
Name Type
@tanstack/react-router Patch
@tanstack/solid-router Patch
@tanstack/vue-router Patch
@tanstack/react-start-client Patch
@tanstack/react-start-rsc Patch
@tanstack/react-start-server Patch
@tanstack/react-start Patch
@tanstack/solid-start-client Patch
@tanstack/solid-start-server Patch
@tanstack/solid-start Patch
@tanstack/vue-start-client Patch
@tanstack/vue-start-server Patch
@tanstack/vue-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 Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

React, Solid, and Vue Links now keep fuzzy path matches active for styling while setting aria-current="page" only for exact path matches. Tests check active status and current-page status separately. The navigation guide and Changeset document the behavior.

Changes: Link current-page accessibility state

Layer / File(s) Summary
React Link matching and rendering
packages/react-router/src/link.tsx, packages/react-router/tests/link-*.test.tsx, docs/router/guide/navigation.md, .changeset/link-aria-current-exact.md
React Links distinguish inactive, fuzzy-active, and exact-current states. Fuzzy matches retain active status and styling; only exact matches receive aria-current="page". Tests, documentation, and the Changeset reflect this distinction.
Solid Link matching and rendering
packages/solid-router/src/link.tsx, packages/solid-router/tests/link-*.test.tsx, packages/solid-router/tests/server/link-path-matching.test.tsx, packages/solid-router/tests/link-path-cases.ts
Solid Links distinguish fuzzy-active and exact-current matches. Client and server tests check active status separately from aria-current.
Vue Link matching and rendering
packages/vue-router/src/link.tsx, packages/vue-router/tests/link-*.test.tsx
Vue Links distinguish fuzzy-active and exact-current matches in client and server rendering. Tests check active status separately from aria-current.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sheraff, schiller-manuel

Merge Risk: Minimal · up to ad960

Links now set aria-current="page" only on exact pathname matches. Ancestor links stay visually active. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Link aria-current is now set only on exact pathname matches. The raw summary and objectives confirm that fuzzy or ancestor links stay visually active but do not receiv…
Description check Passed The description follows the template. It has the Changes section with motivation, linked issue #8979, and a note that the docs and changeset are included. The checklist is complete and marked, and the…
Linked Issues check Passed Issue #8979 requires (1) at most one aria-current="page" for the exact current page, (2) fuzzy ancestors may stay visually active, (3) documentation of how the default affects aria-current in hierarch…
Out of Scope Changes check Passed All changes relate to the issue. The react-router, solid-router, and vue-router link.tsx changes implement the aria-current split. The matching test updates (link-departing-scope, link-path-matching, …
Full details: Title check

Explanation

The title names the main change: Link aria-current is now set only on exact pathname matches. The raw summary and objectives confirm that fuzzy or ancestor links stay visually active but do not receive aria-current="page". The title uses the fix: prefix, which fits the bug described in issue #8979.

Full details: Description check

Explanation

The description follows the template. It has the Changes section with motivation, linked issue #8979, and a note that the docs and changeset are included. The checklist is complete and marked, and the release impact section is filled in. It discloses no AI authorship, but the template's AI-authored PR rules only apply if AI wrote the PR, and the description does not say whether it did. The description is terse and clear.

Full details: Linked Issues check

Explanation

Issue #8979 requires (1) at most one aria-current="page" for the exact current page, (2) fuzzy ancestors may stay visually active, (3) documentation of how the default affects aria-current in hierarchical navigation. The reviewed head meets these in the framework link implementations. In packages/react-router/src/link.tsx, resolveIsActive returns 0 (inactive), 1 (fuzzy ancestor), or 2 (exact path). applyLinkState sets data-status="active" for any active state, and sets aria-current="page" only when active > 1. The server path (getServerLinkProps) uses the same logic. The PR applies the same change in solid-router and vue-router. The navigation guide adds a note under Active Options. Tests in link.test.tsx and link-path-matching.test.tsx check that at /settings/privacy only the Privacy link has aria-current, while Settings stays active. Homepage consistency (issue point 4) is only partly addressed: the root-link fuzzy behavior is not changed by this PR and no test was found that asserts fuzzy Home behavior. This is a minor gap and does not block the core requirements. The issue does not request a change to the default exact setting.

Full details: Out of Scope Changes check

Explanation

All changes relate to the issue. The react-router, solid-router, and vue-router link.tsx changes implement the aria-current split. The matching test updates (link-departing-scope, link-path-matching, link-selector, link.test.tsx, server tests) cover the new behavior. The test helpers now detect activity through data-status instead of aria-current, which follows from the change. The navigation.md note implements the documentation request. The changeset documents the published behavior change. No unrelated functional change was identified in the summary or in the react link.tsx diff.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 61d5cdd and ad960fb.

Files selected for processing: 17

  • .changeset/link-aria-current-exact.md
  • docs/router/guide/navigation.md
  • packages/react-router/src/link.tsx
  • packages/react-router/tests/link-departing-scope.test.tsx
  • packages/react-router/tests/link-path-matching.test.tsx
  • packages/react-router/tests/link-selector.test.tsx
  • packages/react-router/tests/link.test.tsx
  • packages/solid-router/src/link.tsx
  • packages/solid-router/tests/link-departing-scope.test.tsx
  • packages/solid-router/tests/link-path-cases.ts
  • packages/solid-router/tests/link-path-matching.test.tsx
  • packages/solid-router/tests/link.test.tsx
  • packages/solid-router/tests/server/link-path-matching.test.tsx
  • packages/vue-router/src/link.tsx
  • packages/vue-router/tests/link-departing-scope.test.tsx
  • packages/vue-router/tests/link-path-matching.test.tsx
  • packages/vue-router/tests/link.test.tsx

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

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.

Default activeOptions.exact can result in multiple aria-current

1 participant