fix: render CardLink as native button when no href is provided#3476
Merged
fix: render CardLink as native button when no href is provided#3476
Conversation
Contributor
✅ No New Circular DependenciesNo new circular dependencies detected. Current count: 0 |
Contributor
📦 Alpha Package Version PublishedUse Use |
Contributor
🔍 Visual review for your branch is published 🔍Here are the links to: |
Contributor
Coverage Report for packages/react
File Coverage
|
||||||||||||||||||||||||||||||||||||||
3ceaa3b to
0a08f14
Compare
When CardLink is used without an href (onClick-only), the underlying Link component marks it as disabled with aria-disabled="true", making it inaccessible to keyboard and screen reader users despite being functionally clickable. Render a native <button> instead to get proper keyboard support and correct a11y semantics. Co-authored-by: Claude <noreply@anthropic.com>
0a08f14 to
1eb1b75
Compare
sauldom102
approved these changes
Feb 23, 2026
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.
Summary
<button>when nohrefis provided (onClick-only usage), instead of going through theLinkcomponent which marks it asaria-disabled="true"Problem
When
CardLinkis used without anhref(e.g. in Factorial'sBalanceCounterwidget which passesonClickbut nourl), the underlyingLinkcomponent inlinkHandler.tsxevaluates!props.hrefas truthy and setsisDisabled = true. This renders a<span aria-disabled="true" disabled="">withrole="button"— semantically misleading and inaccessible:<span>)role="button"+aria-disabled="true"contradicts the element's actual behaviorSolution
CardLinknow branches onhref:href→ renders a native<button type="button">with proper a11y semanticshref→ unchanged behavior viaLinkAnchor-specific props (
target,rel,download) are stripped when rendering as<button>.Alternatives Considered
Fix in
Link/linkHandler.tsx: Change theisDisabled = !props.href || disabledlogic soLinkdoesn't mark itself disabled whenhrefis absent butonClickis present. This would fix it globally for allLinkconsumers.We opted against this because:
Link's core disabled logic could have unintended side effects across the design system<button>is the semantically correct element for a click-only action — it's not a link without a destination, it's an action triggerCardLinkhas zero risk to otherLinkconsumersTesting
Card.test.tsx(button rendering, click handler, link fallback)WithClickableLink,WithHrefLinkin Card storiesWithOnClickOnlyLinkin Widget stories