Button component: link buttons should not use aria-disabled #62281
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Package] Components
/packages/components
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
Discovered while checking #62080
The Button component accepts a
href
prop which is supposed to be an URL. When set, the Button renders an<a>
element: a link with a proper href attribute.However, when the Button component receives also the
disabled
and;__experimentalIsFocusable
props both set totrue
, the rendered link gets anaria-disabled="true"
attribute.That's not correct for two reasons:
<a>
element.Weirdly enough, when setting
__experimentalIsFocusable
tofalse
and keeping thehref
prop, the Button is rendered as a disabled<button>
element.Rendered invalid HTML example:
It is worth mentioning that links can't 'really' be disabled. Their real nature is to not be disabled. The defautl action can be prevented via JavaScript to make a click event do nothing but that's less than ideal. It's against the nature of a link.That's the reason why an
aria-disabled="true"
ordisabled
attribute on<a>
elements are invalid HTML.Step-by-step reproduction instructions
__experimentalIsFocusable
anddisabled
props are set totrue
.href
prop tohttps://wordpress.org
<a>
element with anaria-disabled="true"
attribute.Screenshots, screen recording, code snippet
aria-disabled="true" invalid HTML
disabled invalid HTML
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: