feat: Add support for disabledReason for inline link buttons - #4996
Open
vikaskale2722 wants to merge 1 commit into
Open
feat: Add support for disabledReason for inline link buttons#4996vikaskale2722 wants to merge 1 commit into
vikaskale2722 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
vikaskale2722
marked this pull request as ready for review
September 10, 2026 14:29
vikaskale2722
requested review from
NathanZlion
and removed request for
a team
September 10, 2026 14:29
avinashbot
requested review from
a team,
SpyZzey and
avinashbot
and removed request for
a team and
NathanZlion
September 11, 2026 13:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
disabledReasononly worked on thenormal,primaryandiconbutton variants. If we passed it tolink,inline-linkorinline-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 theisDisabledWithReasonflag rather than the variant, so nothing else needed touching.One thing reviewers should know: when
disabledReasonis set, the button drops the nativedisabledattribute and usesaria-disabledinstead. That's not new, it's been the behavior fornormal/primary/iconall 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-utilsisDisabled()handles both).Two components have a side-effect as they render Button as their trigger and forward the prop -
ButtonDropdownwithvariant="inline-icon"CopyToClipboardwithvariant="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 onlylinkwas unsupported, which was already wrong, andCopyToClipboard's correctly excludedinlineand 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 assertedtabIndex="-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.eachinbutton.test.tsxfrom 3 variants to 6, which runs its 14 assertions across both the<button>and<a>branches. Addedinline-iconto ButtonDropdown's variant list, and turned CopyToClipboard's disabled-reason test into atest.eachover all three of its variants.To Test :
npm start#/light/button/disabled-reason,#/light/button-dropdown/disabled-reasonand#/light/copy-to-clipboard/disabled-reason(new page)The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.