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

fix(react-router,solid-router,vue-router): keep a caller-set role on a disabled Link - #8993

Open
YehudaMenahem wants to merge 1 commit into
TanStack:mainfrom
YehudaMenahem:cursor/fix-link-disabled-preserve-role-56ed
Open

YehudaMenahem wants to merge 1 commit into
TanStack:mainfrom
YehudaMenahem:cursor/fix-link-disabled-preserve-role-56ed

Conversation

@YehudaMenahem

@YehudaMenahem YehudaMenahem commented Nov 27, 2026 •

Copy link
Copy Markdown

🎯 Changes

Fixes #8981.

A disabled Link set role="link" after the caller's props were merged, so an explicit role was always overwritten. Now role="link" is only the default when no role was given. Same fix in react, solid, and vue.

✅ 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
    • Disabled or blocked links now preserve a caller-specified accessibility role across React, Solid, and Vue. When no role is supplied, they continue to default to role="link" and indicate their disabled state to assistive technologies.

…a disabled Link

A disabled Link only defaults to role="link" when the caller did not set a
role, so composition with host-injected roles (e.g. menuitem) still works.
Fixes TanStack#8981.

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: cc595d2

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

Disabled links in the React, Solid, and Vue routers now preserve a supplied role and default to role="link" only when no role is set. Tests cover disabled and blocked links, including aria-disabled and omitted href.

Changes: Disabled Link role preservation

Layer / File(s) Summary
Preserve supplied roles
packages/react-router/src/link.tsx, packages/solid-router/src/link.tsx, packages/vue-router/src/link.tsx, .changeset/link-disabled-keeps-role.md
Each adapter defaults the role to link only when no role is supplied. The changeset declares patches for the three router packages.
Test disabled-link roles
packages/react-router/tests/link-state-props.test.tsx, packages/solid-router/tests/link-element-props.test.tsx, packages/vue-router/tests/link.test.tsx
Tests check supplied and default roles on disabled or blocked links. They also check that href is omitted and aria-disabled="true" is set.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • TanStack/router#8982: It changes the same disabled-link role behavior in the same three adapters and addresses the same issue.

Suggested reviewers: sheraff, schiller-manuel

Merge Risk: Minimal · up to cc595

Disabled links in the React, Solid, and Vue routers now keep a caller-supplied role and default to role="link" only when none is set. The change is small and localized with tests, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the three affected packages and the main fix: a disabled Link keeps a caller-set role. The changeset, the link.tsx changes in React, Solid, and Vue, and the added tests all match this.…
Description check Passed The description covers the change and its motivation. It states that a disabled Link overwrote an explicit role, that role="link" is now only the default, and that the same fix applies to React, Solid…
Linked Issues check Passed Issue #8981 requires that a caller-supplied role survive disabled, and that role="link" apply only when no role is supplied. The reviewed head meets this in all four adapters:
- React (`packages/r…
Out of Scope Changes check Passed All changed files relate to the #8981 fix:
- The four adapter source edits change only the disabled-role logic. The Solid edit also removes STATIC_DISABLED_PROPS, which exists only for that logic.
-…
Full details: Title check

Explanation

The title names the three affected packages and the main fix: a disabled Link keeps a caller-set role. The changeset, the link.tsx changes in React, Solid, and Vue, and the added tests all match this. The title is specific and accurate.

Full details: Description check

Explanation

The description covers the change and its motivation. It states that a disabled Link overwrote an explicit role, that role="link" is now only the default, and that the same fix applies to React, Solid, and Vue. It links issue #8981. The checklist is filled in and the changeset is noted. It does not disclose AI authorship, which the template's AI-authored PR rules request. The description is short but clear, and it is mostly complete.

Full details: Linked Issues check

Explanation

Issue #8981 requires that a caller-supplied role survive disabled, and that role="link" apply only when no role is supplied. The reviewed head meets this in all four adapters:

  • React (packages/react-router/src/link.tsx, applyLinkState): props.role = 'link' became props.role ??= 'link'. The role set by the caller or by a host clone is kept. aria-disabled is still set.
  • Vue (packages/vue-router/src/link.tsx, combineResultProps and getExternalLinkProps): result.role = 'link' became result.role ??= 'link' in both disabled branches.
  • Solid (packages/solid-router/src/link.tsx, createLinkProps): the shared STATIC_DISABLED_PROPS object, which forced role, was removed. Disabled links now set role='link' only when options.role === undefined, and always set aria-disabled.
  • Tests cover the behavior in React (link-state-props.test.tsx), Solid (link-element-props.test.tsx), and Vue (link.test.tsx). The tests check preserved caller roles, preserved activeProps roles, the link default, and omitted href.

The Solid check reads options.role. I did not trace every Solid code path that merges props after this point. The Solid tests cover the element-prop and state-prop cases, so this is treated as sufficient evidence.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the #8981 fix:

  • The four adapter source edits change only the disabled-role logic. The Solid edit also removes STATIC_DISABLED_PROPS, which exists only for that logic.
  • The three test files cover the new disabled-role behavior in React, Solid, and Vue.
  • .changeset/link-disabled-keeps-role.md records the patch for the affected packages, as the PR checklist requires.
    No unrelated behavior change appears in the reviewed summary or diffs.
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 cc595d2.

Files selected for processing: 7

  • .changeset/link-disabled-keeps-role.md
  • packages/react-router/src/link.tsx
  • packages/react-router/tests/link-state-props.test.tsx
  • packages/solid-router/src/link.tsx
  • packages/solid-router/tests/link-element-props.test.tsx
  • packages/vue-router/src/link.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; 9 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.

Link disabled unconditionally overwrites an inherited role on the rendered anchor

1 participant