Describe the bug
ARC Toolkit incorrectly flags an error, "ARIA attribute is not allowed: The aria-label attribute is not allowed on the generic role", for aria-label on a <label> element that wraps an <input>.
ARC appears to unconditionally treat <label> as having the generic role, but the ARIA in HTML specification distinguishes two cases:
If a label element is implicitly or explicitly associated with a labelable element then no role
Otherwise […] any role, though generic SHOULD NOT be used.
When the label is associated with a labelable element (as in the reproduction case below), it has "no role" — not generic. Naming is only prohibited "if exposed as the generic role, or if exposed as another role which prohibits naming." Since the label has no role, this condition does not apply, and the spec falls through to:
Otherwise, global aria-* attributes.
aria-label is a global ARIA attribute, so it is permitted in this case.
To Reproduce
- Go to this example from Designsystemet.no's storybook
- Run tests on the page in ARC Toolkit
- See that an error is flagged for each of the labels
Expected behavior
No error should be flagged, since the <label> is implicitly associated with the <input type="radio"> (a labelable element) and therefore has "no role", not generic.
Screenshots
Version information
- Browser and version: Chrome 149.0.7827.54 (Official Build) (arm64)
- ARC Toolkit version: 5.7.10
Additional context
Chrome's accessibility tree confirms the aria-label is functioning correctly. The wrapped <input> receives its accessible name from the label:
Name: "Venstrestilt"
From label (wrapped): label "Venstrestilt"
Role: `radio`
This pattern is used by Designsystemet to improve accessibility in a Toggle group with icon-only items, by wrapping each item in a Tooltip.
Describe the bug
ARC Toolkit incorrectly flags an error, "ARIA attribute is not allowed: The
aria-labelattribute is not allowed on thegenericrole", foraria-labelon a<label>element that wraps an<input>.ARC appears to unconditionally treat
<label>as having thegenericrole, but the ARIA in HTML specification distinguishes two cases:When the label is associated with a labelable element (as in the reproduction case below), it has "no role" — not
generic. Naming is only prohibited "if exposed as the generic role, or if exposed as another role which prohibits naming." Since the label has no role, this condition does not apply, and the spec falls through to:aria-labelis a global ARIA attribute, so it is permitted in this case.To Reproduce
Expected behavior
No error should be flagged, since the
<label>is implicitly associated with the<input type="radio">(a labelable element) and therefore has "no role", notgeneric.Screenshots
Version information
Additional context
Chrome's accessibility tree confirms the
aria-labelis functioning correctly. The wrapped<input>receives its accessible name from the label:This pattern is used by Designsystemet to improve accessibility in a Toggle group with icon-only items, by wrapping each item in a Tooltip.