CustomSelectControl: fix describedBy
implementation and docs
#63568
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Package] Components
/packages/components
[Status] In Progress
Tracking issues with work in progress
[Type] Regression
Related to a regression in the latest release
Description
Discovered while investigating #63483
The
CustomSelectControl
component has adescribedBy
prop that accepts a string.It is supposed to provide an accessible description for the toggle button that opens the custom select.
Unfortunately, both the implementation and the docs are wrong and the component renders non-accessible markup.
An example can be seen for the font appearance setting. It can be reproduced in the Storybook as well.
Turns out the value passed to the
describedBy
prop is just rendered as the value of thearia-describedby
attribute.gutenberg/packages/components/src/custom-select-control/index.tsx
Line 157 in c54c002
Instead, the
aria-describedby
attribute accepts an ID reference that points to an element containing the description.For example, the font appearance setting renders this markup:
aria-describedby="Currently selected font appearance: Medium"
The correct usage would be:
The component should be refactored to actually render another element that contains the description, referenced by an ID, much like what the Button component does.
At that point, the
describedBy
prop should be renamed todescription
.The readme and types.ts must be fixed as well. For example, this prop description doesn't appear to be correct:
Step-by-step reproduction instructions
aria-describedby="Currently selected font appearance: Medium"
describedBy
prop tola la la
.aria-describedby="la la la"
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: