Incorrect report of jsx-a11y/label-has-associated-control and jsx-a11y/label-has-for
See original GitHub issueGetting
26:21 error A form label must be associated with a control jsx-a11y/label-has-associated-control
26:21 error Form label must have ALL of the following types of associated control: nesting, id jsx-a11y/label-has-for
Even though the element is nested inside the label and the htmlfor and id are set.
<label htmlFor="filters">
Filter by
<select id="filters" className="form-control">
<option value="0" selected>
All Snippets
</option>
<option value="1">Featured</option>
<option value="2">Most popular</option>
<option value="3">Top rated</option>
<option value="4">Most commented</option>
</select>
</label>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:15 (5 by maintainers)
Top Results From Across the Web
label-has-associated-control documentation incorrect #457
Hi,. https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/v6.1.0/docs/rules/label-has-associated-control.md.
Read more >How to Fix JSX-A11Y Label-Has-Associated-Control Errors
In this post we'll explore the label-has-associated-control error thrown by ESLint ... A form label must be associated with a control jsx-a11y/label-has.
Read more >EsLint rule for label - Stack Overflow
The documentation for jsx-a11y/label-has-associated-control has a section about how to resolve this error: github.com/evcohen/eslint-plugin-jsx- ...
Read more >eslint-plugin-jsx-a11y - npm
Why? This plugin does a static evaluation of the JSX to spot accessibility issues in React apps. Because it only catches errors in...
Read more >Incorrect report of jsx-a11y/label-has-associated-control and ...
Incorrect report of jsx-a11y/label-has-associated-control and ... following types of associated control: nesting, id jsx-a11y/label-has-for.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I stumbled on this issue today. I’m curious if it was fully resolved? Below are some examples of code where this error is popping up for me when I don’t think it should be. I am using the latest airbnb eslint config which uses version 6.2.1 of jsx-a11y.
Select:
Meter:
Progress:
@Stopa thank you for the report. There are two things happening here.
One, there is indeed a bug. The rule doesn’t include the
<select>
element as one of the default control elements. You can configure the rule to includeselect
as acontrolElement
for now until a future release with a fix. Here’s the fix: #503Two, you’re example code doesn’t include a text for a label. You can use text content, or
aria-label
oraria-labelledby
or define a prop that contains the label text and configure the rule to recognize that prop. But text you must have.