Global styles menu: avoid unnecessary mismatch between visible label and accessible name #65112
Closed
2 tasks done
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
[Package] Edit Site
/packages/edit-site
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
See related discussion on #22332
Cc @joedolson @alexstine
For the highest level of accessibility, the visible label of a control should determine the control's accessible name.
Sometimes, with good intent, both Core and Gutenberg use the
aria-label
attribute to provide more context but by doing so a mismatch between the visible label and the actual accessible name occurs.While the expanded info in the
aria-label
may be beneficial for blind screen reader users, it introduces potential barriers for other users. For example:The Web Content Accessibility Guidelines success criterium Label in Name states that the accessible name must contain the visible label and that the best practice is to have the text of the visible label at the start of the name.
Unfortunately, that doesn't work with some voice control software, which makes the WCAG criterium arguably useful.
As such, each time there's a mismatch between visible label and actual accessible name, a new accessibility barrier is introduced for some users. This kind of mismatch should be avoided when possible.
I'd like to reinstate a good general principle:
Important
When possible, let the visible label of a control be its accessible name. Do not override or expand with screen reader text or aria-label / aria-labelledby.
A good example of unnecessary mismatch is in the Global Styles root menu. Screenshot:
Where the buttons visible labels are:
However, these buttons do have aria-label attributes that only adds the word 'styles'. As such, their accessible name becomes, respectively:
This mismatch prevents users of some voice control software to use a voice command.
In this specific case, the added word 'styles' doesn't add much value. These buttons are already placed in a panel that has a heading 'Styles'. The context appears to be clear enough and the mismatch should be avoided. Keeping things simple is always the best option.
When some meaningful, useful, additional context and information are necessary, a better option would be to place the extra info in the control description rather than unnecessarily altering the accessible name.
Step-by-step reproduction instructions
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: