The RadioControl component renders invalid and not accessible markup #52890
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Package] Components
/packages/components
[Package] Edit Site
/packages/edit-site
[Type] Bug
An existing feature does not function as intended
Description
While investigating the Post Status UI in teh Site editor in #52885 and #52634 I noticed the
RadioControl
component is open to misuse by developers and has some limitations that cause accessibility problems. Both the component and its implementations should be reviewed thoroughly.At a first check:
label
prop renders a stray label element that is not associated with any input.PageStatus
component the description has been added within the label, thus making the accessible name of the inputs very confusing: name and description should be separated.help
prop renders some additional text at the end of all radio buttons. This text is associated with all the radio buttons via aria-describedby. This may be useful in some cases but it's likely to be redundant and confusing. In most cases, each radio button will need its won description. Worth reminding aria-describedby may accept multiple ID refs.In the screenshot below I made some visually hidden elements visible to better illustrate, and set some options:
PageStatus
.In all three case the HTML is invalid. The labelling isn't ideal, given the stray label.
Given the component limitations, maybe it's not a case that in the Post editor, in the very similar Post visibility UI, an ad-hoc implementation has been made, see the PostVisibilityChoice component.
Ideally, the
RadioControl
component should behave more like the PostVisibilityChoice one, or at least produce valid markup, render fieldset+legend, and be more flexible to be able to replace PostVisibilityChoice.Cc @ciampo @mirka
Step-by-step reproduction instructions
POST VISIBILITY
text is actually a label element that is not associated with any input.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
The text was updated successfully, but these errors were encountered: