SSAgov / ANDI

A tool to test web content for accessibility and 508 compliance.
https://www.ssa.gov/accessibility/andi/help/howtouse.html
Other
302 stars 76 forks source link

Labels not seen by ANDI when an input has the "switch" role #130

Open Christian-Sibo-ONRR opened 2 years ago

Christian-Sibo-ONRR commented 2 years ago

For the following markup:

<input type="checkbox" role="switch" id="my-switch" aria-checked="false" aria-disabled="false" value>
<label for="my-switch">My Label</label>

ANDI reports two problems:

  1. "Switch Element has no accessible name."
  2. "Explicit <label[for]> only works with form elements."

If you change the input's role to "checkbox", the errors go away.

I believe this is a false-positive due to ANDI not properly assigning the label to the input. No other accessibility tool is reporting this as a problem and I don't see any restriction in the HTML spec to say that role="switch" is not considered a form element.

JohnCotterSSA commented 2 years ago

Thank you for the detailed analysis. This seems like a bug with an easy fix. We will look into fixing this soon.