wallaby icon indicating copy to clipboard operation
wallaby copied to clipboard

Wallaby can't fill in an input that is implicitly associated with its label via nesting

Open jonleighton opened this issue 3 years ago • 0 comments

<input> elements may be nested inside a <label> element, and in this case the association is implicit and a for attribute is not needed on the <label>. Example from MDN:

<label>Do you like peas?
  <input type="checkbox" name="peas">
</label>

Wallaby doesn't support this use case, at least when selecting an option in a radio list. It raises this errors:

 ▏ ▏** (Wallaby.QueryError) The text '...' matched a label but the label has no 'for'
 ▏ ▏attribute and can't be used to find the correct element.

 ▏ ▏You can fix this by including the `for="YOUR_INPUT_ID"` attribute on the
 ▏ ▏appropriate label.

jonleighton avatar Feb 21 '22 04:02 jonleighton