Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label-has-for is not checking if input has the correct id #768

Open
edfrias opened this issue Apr 24, 2023 · 2 comments
Open

label-has-for is not checking if input has the correct id #768

edfrias opened this issue Apr 24, 2023 · 2 comments

Comments

@edfrias
Copy link

edfrias commented Apr 24, 2023

Hi everyone,

First of all thanks for creating this tool, it really helps too much!

I recently came to an issue about how labels should control the addition of id/for to the combo of label-input.

So, right now the rule only checks if the input is nested inside a label, or if a label has a for attribute but not if the input component has indeed the correct id.

Here is how I define the configuration inside eslintrc:

Captura de pantalla 2023-04-24 a las 12 14 30

So you could have a properly created label without an id on the following input like so:
Captura de pantalla 2023-04-24 a las 12 48 56

Also the rule complains if the id is set but not the for:
Captura de pantalla 2023-04-24 a las 12 53 15

So my guest is that the validate function shouldn't only been looking for the for attribute on labels, but also should be looking for the same string inside the for into the input's id that is nested or following the label node.

I'm based on how W3C tells us how to define properly our form components.

@edfrias
Copy link
Author

edfrias commented Apr 24, 2023

Hey @vhoyer ! Thanks for the reply!

I've been reviewing all those issues and I don't feel any of those are related with what I'am describing, even though form-control-has-label might seems to be close.

The thing is, Oruga UI's o-switch component already creates a label whose have inside a proper labelled-by aria if you provide it as a prop. Which solves any accessibility issues as it creates a nesting label and then add a proper id to an element you provide through a slot.

By looking at the rules, form-control-has-label does not checks for any input type "checkbox" which is my specific case, but also neither rules, form-control-has-label nor label-has-for, are checking the resulting input having a correct id that should be matching the same string as the for value located in the label tag.

I don't know if I'm explaining myself right, but I'm going to try to create a PR in order to let you see which is the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants