-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
label rule does not properly detect multiple labels #1057
Comments
Good point. Out of curiosity, is this a false positive you saw on a live site some place, or is this more of a theoretical issue? |
It is a false positive, detected while testing a front end framework. The implementation was using the second "label" as a shim for the image of a "toggle switch" that visually obscures a checkbox and, apparently, it was easier to simply get the "clickability" by using the label tag than to attach a listener. |
In the second scenario/ example below:
the violation summary suggests Are you suggesting that the target html should have been the other Looking through the @WilcoFiers - thoughts? |
From my understanding of the ARIA spec, if you set aria-labelledby, it overrides other labeling strategies. This is described here: https://www.w3.org/TR/accname-1.1/#mapping_additional_nd_te So, this input does not have two labels. It has only the one in the IDREF from the aria-labelledby. You can verify this working in a browser by taking the checkbox snippet above and inspecting it in the Chrome Accessibility tree panel, in the computed properties panel: the accessible name of the input is "label one," not "label one label two." |
Should the checks be altered to cater for overriding by various |
@kensgists We're looking to make the multiple-label check into its own best practice rule. I do think multiple labels is a poor practice, as it gets confusing, it doesn't get any better from adding aria-labelledby to it. Would you agree that example should be a failure of a best practice? |
PR Merged. Closing issue. |
This issue may be related to issue #855
This code:
is appropriately flagged as a violation.
There are multiple labels, and it is ambiguous whether both labels should be associated with the checkbox, or only one should be associated, and, if only one is associated, which one, or, if both are associated, in what order they should be associated.
On the other hand, this version is unambiguous, since it has only one programmatically associated label, yet it still flags as a violation:
(Note: Both code snippets parse as valid HTML 5.)
The text was updated successfully, but these errors were encountered: