Audit usage of explicit aria-label
on Button component implementations
#66271
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Package] Components
/packages/components
[Type] Code Quality
Issues or PRs that relate to code quality
Description
It appears that in some cases some
Button
components use an explicitaria-label
prop to render anaria-label
HTML attribute, which in turn determines the icon button tooltip (if it's an icon button). Example:gutenberg/packages/block-editor/src/components/border-radius-control/linked-button.js
Lines 12 to 21 in 91272a2
This pattern should be audited across the entire codebase as it's not a best practice.
Setting an explicit
aria-label
signals two possible cases, both less than ideal:aria-label
is used in a way that the accessible name mismatches the Button text or tooltip. This is not OK for accessibility.aria-label
is just unnecessary, like in the example above. In that case, the wrapping Tooltip component uses the samelabel
variable used foraria-label
. In this case, the Tooltip component can be removed and the variable passed to thelabel
prop of the Butotn.Step-by-step reproduction instructions
N/A
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: