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

MenuItem: split content and info prop into accessible name and accessible description #58720

Open
afercia opened this issue Feb 6, 2024 · 1 comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Feb 6, 2024

Description

The MenuItem component conent is actuall determined by its children and the value of the info prop.

As such, both the content and the info end up being the actual label of this UI control, i.e. the accessible name.

This is less than ideal because the info is typically used to provide a visual descriotion of the control label. However, thie description is part of the name of the control, thus labeling the control with extraneous information.
Generally:

  • A control's should be short and sufficiently meaningful.
  • An additional description may be provided separately from the accessible name. It should be rendered into a separate element with an ID that is referenced via aria-describedby.

Puttint together the name and description provides users with a label that is semantically too long and confusing. Asssistive technologies use the label (name) which in many cases is just too long and may even be a barrier for some users.

Examples:

The URL input UI for images shows some preset suggestions in a menu with menuitems. The 'Expand on click` last item was added in #57608

Visually, the label 'Expand on click' and the description 'Scale the image with a lightbox effect.' are separated and style differently:

Screenshot 2024-02-06 at 09 10 53

However, that's only visuals. Both strings are the actual content of the MenuItem button. As such, the accessible name of the menu item is:

Expand on click Scale the image with a lightbox effect.

Screenshot 2024-02-06 at 10 35 31

Aside: I don't think a descriptive text in the menu item should end with a period.

That string is less than ideal:

  • Too noisy for screen reader users.
  • Too long to be easily activated with a voice command for speech recognition software users.
  • Semantically not ideal as it adds a description into the name.

There are many other cases where a menu item has descriptions that are actually rendered as part of the name. For example: block alignment controls:

Screenshot 2024-02-06 at 11 11 52

Options menu items, etc.:

Screenshot 2024-02-06 at 11 13 03

Also in these cases, such long accessible names are less than ideal, e.g.:

Top toolbar Access all block and document tools in a single place

Looking at the code, it appears the only purpose of the info tet is to provide additional text that looks like a description. There's no semantics at all.

<span className="components-menu-item__info-wrapper">
<span className="components-menu-item__item">{ children }</span>
<span className="components-menu-item__info">{ info }</span>
</span>

Originally introduced in #10802

Step-by-step reproduction instructions

  • Inspect in your browser dev tools one of these menu items with descriptions.
  • Observe the visual description is avtually part of the item label (its content) thus determining the accessible name

Screenshots, screen recording, code snippet

More screenshots of how these long accessible names are announced by a screen reader:

Screenshot 2024-02-06 at 11 22 08

Screenshot 2024-02-06 at 11 23 10

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). [Package] Components /packages/components labels Feb 6, 2024
@afercia
Copy link
Contributor Author

afercia commented Feb 6, 2024

Disabling CSS helps understand also visually these MenuItems (under the hood they are button elements) have too long labels. I'm not sure no one would ever craft buttons with such long text:

Screenshot 2024-02-06 at 11 35 11

Screenshot 2024-02-06 at 11 40 07

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). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant