BaseControl should require an id or create one if missing #6989
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Type] Code Quality
Issues or PRs that relate to code quality
Is your feature request related to a problem? Please describe.
As mentioned in #6922, it's possible to create a
BaseControl
element that outputs a<label>
not associated with any element. This causes issues like #6918. This kind of disassociated label markup is frustrating and a personal pet-peeve of mine online. We should strive never to make a label that is unassociated 😆Describe the solution you'd like
Make
id
a requiredprop
ofBaseControl
such that omitting it causes a linting error. And/or create an internal ID automatically if an explicit one isn't supplied, so the label of aBaseControl
component gets linked to its single child element (if it only has one).Describe alternatives you've considered
My review in #6922 mentions that education here is not enough, as this is easily omitted. (Especially when the label prop is supplied without an iD).
It might be that a default ID being created if none is supplied would (also) work.
The text was updated successfully, but these errors were encountered: