Skip to content

label-has-associated-control failing for correct structure #1885

@bteng22

Description

@bteng22

Looks like updating to 17.1.0 enables label-has-associated-control but it seems to be failing for a correct label/input. To my understanding, the correct structure could either be a nested input within a label OR use the htmlFor prop with a valid DOM ID.

In this case, we're using htmlFor:

const Foo () => {
  return (
        <label htmlFor="filterAll">
          ...
        </label>
        <input id="filterAll" />
  )
}

and the linter is giving us the following error

error A form label must be associated with a control jsx-a11y/label-has-associated-control

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions