Skip to content

feat: Add support for disabledReason for inline link buttons - #4996

Open
vikaskale2722 wants to merge 1 commit into
mainfrom
dev-v3-vgkale-button-disabled-reason-variants
Open

feat: Add support for disabledReason for inline link buttons#4996
vikaskale2722 wants to merge 1 commit into
mainfrom
dev-v3-vgkale-button-disabled-reason-variants

Conversation

@vikaskale2722

@vikaskale2722 vikaskale2722 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Description

disabledReason only worked on the normal, primary and icon button variants. If we passed it to link, inline-link or inline-icon, the tooltip did not work, nor any reason/warnings exposed to screen readers. This code change makes it work on all the six variants.

The whole fix is one condition in src/button/internal.tsx, adding the three missing variants to the gate. Everything downstream already keyed off the isDisabledWithReason flag rather than the variant, so nothing else needed touching.

One thing reviewers should know: when disabledReason is set, the button drops the native disabled attribute and uses aria-disabled instead. That's not new, it's been the behavior for normal/primary/icon all along, because a natively disabled button can't be focused or hovered, so the tooltip could never be reached. This PR just extends it to three more variants. Plain <Button disabled /> is untouched.

Worth calling out in the release notes, since toBeDisabled() will stop matching for these variants (test-utils isDisabled() handles both).

Two components have a side-effect as they render Button as their trigger and forward the prop -

  1. ButtonDropdown with variant="inline-icon"
  2. CopyToClipboard with variant="inline"
    Both combinations were silently inert before. I added tests for them so it doesn't quietly regress later.

Also fixed the docs: Button's JSDoc claimed only link was unsupported, which was already wrong, and CopyToClipboard's correctly excluded inline and would have become wrong. Both are fixed, and the documenter snapshot is regenerated since that text feeds the published API docs.

I deleted the old disabled with reason ignored for %s variant (not applicable) test rather than inverting it, it asserted tabIndex="-1" for the exact case that now yields "0". Both behaviors it covered still have tests elsewhere.

Open question: the disabled and read-only states pattern still lists only primary, normal and icon as supporting this tooltip. So this needs a design call as well as a code review, and the pattern page should be updated if we go ahead.

Related links: Issue #60908

How has this been tested?

Full build and the complete unit test.

On the unit side I widened the existing describe.each in button.test.tsx from 3 variants to 6, which runs its 14 assertions across both the <button> and <a> branches. Added inline-icon to ButtonDropdown's variant list, and turned CopyToClipboard's disabled-reason test into a test.each over all three of its variants.

To Test :

  1. npm start
  2. #/light/button/disabled-reason, #/light/button-dropdown/disabled-reason and #/light/copy-to-clipboard/disabled-reason (new page)

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.67%. Comparing base (0fcf5f7) to head (d2a69a3).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4996   +/-   ##
=======================================
  Coverage   97.67%   97.67%           
=======================================
  Files         960      960           
  Lines       31376    31383    +7     
  Branches    11598    11604    +6     
=======================================
+ Hits        30645    30652    +7     
- Misses        685      724   +39     
+ Partials       46        7   -39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vikaskale2722
vikaskale2722 marked this pull request as ready for review September 10, 2026 14:29
@vikaskale2722
vikaskale2722 requested a review from a team as a code owner September 10, 2026 14:29
@vikaskale2722
vikaskale2722 requested review from NathanZlion and removed request for a team September 10, 2026 14:29
@avinashbot
avinashbot requested review from a team, SpyZzey and avinashbot and removed request for a team and NathanZlion September 11, 2026 13:47
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.

1 participant