Describe the feature you'd like:
There is currently no query, that I know of, that can find a radiogroup <fieldset> by its labeled <legend>. This can be problematic, since multiple radio inputs might have the same text but responsible for different parts of a form.
Example:
<fieldset>
<legend>Do you like ice cream?</legend>
<label><input type="radio" name="iceCream" value="true" />Yes</label>
<label><input type="radio" name="iceCream" value="false" />No</label>
</fieldset>
<fieldset>
<legend>Do you like cookies?</legend>
<label><input type="radio" name="cookies" value="true" />Yes</label>
<label><input type="radio" name="cookies" value="false" />No</label>
</fieldset>
Alternatives that I've seen for this problem (i.e. getByLabelText(/yes/i) don't work, because they'll find radio buttons from both of the groups.
You could also getByRole('group') to find the <fieldset>s, but again you can't select which one based on its labeled <legend>.
I actually wonder if this could just work as a part of getByLabelText 🤔
Anyways, seemed like a valid use case, since this is the "right" way to build accessible radio button groups 😃
Describe the feature you'd like:
There is currently no query, that I know of, that can find a radiogroup
<fieldset>by its labeled<legend>. This can be problematic, since multiple radio inputs might have the same text but responsible for different parts of a form.Example:
Alternatives that I've seen for this problem (i.e.
getByLabelText(/yes/i)don't work, because they'll find radio buttons from both of the groups.You could also
getByRole('group')to find the<fieldset>s, but again you can't select which one based on its labeled<legend>.I actually wonder if this could just work as a part of
getByLabelText🤔Anyways, seemed like a valid use case, since this is the "right" way to build accessible radio button groups 😃