MenuItem: split content and info prop into accessible name and accessible description #58720
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
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:
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:
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.
Aside: I don't think a descriptive text in the menu item should end with a period.
That string is less than ideal:
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:
Options menu items, etc.:
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.gutenberg/packages/components/src/menu-item/index.tsx
Lines 42 to 45 in 1fb5110
Originally introduced in #10802
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
More screenshots of how these long accessible names are announced by a screen reader:
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: