Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global styles menu: avoid unnecessary mismatch between visible label and accessible name #65112

Open
2 tasks done
afercia opened this issue Sep 6, 2024 · 4 comments · May be fixed by #65124
Open
2 tasks done

Global styles menu: avoid unnecessary mismatch between visible label and accessible name #65112

afercia opened this issue Sep 6, 2024 · 4 comments · May be fixed by #65124
Assignees
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

Comments

@afercia
Copy link
Contributor

afercia commented Sep 6, 2024

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:

  • Sighted screen reader users will see the visible label but the screen reader will announce the invisible aria-label.
  • Speech recognition / Voice control users won't be able to activate the control via a voice command, because of the label / accessible name mismatch, at least with some of the voice control software. See discussion on Add screen reader only text format #22332

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:

Screenshot 2024-09-06 at 09 57 46

Where the buttons visible labels are:

  • Typography
  • Colors
  • Shadows
  • Layout

However, these buttons do have aria-label attributes that only adds the word 'styles'. As such, their accessible name becomes, respectively:

  • Typography styles
  • Colors styles
  • Shadow styles
  • Layout styles

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

  • Go to Site Editor > Styles
  • Observe the root menu in the Styles panel.
  • Observe the visible label of the buttons Typography, Colors, Shadows, Layout, mismatches the accessible name provided by the aria-label attributes.

Screenshots, screen recording, code snippet

No response

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
@afercia afercia added [Type] Bug An existing feature does not function as intended [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 labels Sep 6, 2024
@afercia afercia changed the title Global styles root menu: avoid unnecessary mismatch between visible label and accessible name Global styles menu: avoid unnecessary mismatch between visible label and accessible name Sep 6, 2024
@afercia
Copy link
Contributor Author

afercia commented Sep 6, 2024

Same applies to some of the sub-menus, for example the Typography elements:

Screenshot 2024-09-06 at 10 43 43

where, additionally, the Aa should be hidden from assistive technology.

@afercia
Copy link
Contributor Author

afercia commented Sep 6, 2024

Some of the sub menus items use a HTML title attribute that just repeats the visible text. This is redundant and WordPress has being removing this kind of attributes over the last years, see https://core.trac.wordpress.org/ticket/24766 and all the related tickets and chagesets.

Screenshot 2024-09-06 at 12 06 41

@afercia afercia self-assigned this Sep 6, 2024
@afercia
Copy link
Contributor Author

afercia commented Sep 6, 2024

The Typeset button has an aria-label={ __( 'Typeset' ) } that completely mismatches the meaning and visible label:

Screenshot 2024-09-06 at 14 28 14

@afercia
Copy link
Contributor Author

afercia commented Sep 6, 2024

The Palette button conditionally shows:

  • When there are no palette colors, it shows a visible label 'Add colors'.
  • Otherwise, it shows a visual representation of the palette colors. This is not OK for accessibility, as the accessible name provided via an aria-label Edit palette is not visually exposed.

Screenshot 2024-09-06 at 12 10 45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant