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

Inputs missing labels & Labels missing inputs #7

Open
2 tasks
danspratling opened this issue Sep 24, 2020 · 7 comments · Fixed by #43
Open
2 tasks

Inputs missing labels & Labels missing inputs #7

danspratling opened this issue Sep 24, 2020 · 7 comments · Fixed by #43
Labels
a11y feature New feature or request for an a11y check needs more info Further information from author is requested

Comments

@danspratling
Copy link
Contributor

danspratling commented Sep 24, 2020

Proposal:

Inputs missing labels (often when Placeholders are being used as labels) might have unclear intentions.

Issue:

<input type="text" placeholder="Email" />

The placeholder in the above example is rarely read by screenreaders

Issue 2:

<label>Email</label>
<input type="text" />

The label in the above example exists, but is not associated with an element so will often be misinterpreted.

Solution:

<label for="email">Email Address</label>
<input name="email" type="text" />

The above is the best-accepted solution, which most screen readers understand (unlike <label><input></label>).

We should check 2 things

  • Does a label have a for attribute present and populated
  • Does an input have a name attribute present and populated

This won't account for if any inputs/labels have attributes present but their counterparts don't exist, however.

@danspratling danspratling added a11y feature New feature or request for an a11y check good first issue Good for newcomers labels Sep 24, 2020
@jackdomleo7
Copy link
Owner

I like this. But what about this scenario, which I often do:

<label>
  <span>Email</span>
  <input type="email" />
</label>

I think the above solution would highlight this as an error? 🤔

I have to admit, my knowledge and research on this method in terms of accessibility where the <label> wraps the <input> is not solid.

@jackdomleo7 jackdomleo7 added the needs more info Further information from author is requested label Sep 24, 2020
@danspratling
Copy link
Contributor Author

It would, but I think as someone suggested to us on twitter, this approach is flawed as some screen readers don't correctly associate the inner input with the wrapping label.

So maybe in this case we would show a warning?

Warning: some screen readers don't correctly understand labels not directly associated with inputs using for/name attributes. It is recommended adjusting the approach

@jackdomleo7
Copy link
Owner

Ok, that sounds good. I think we should look deeper into #4 first so this works effectively.

@danspratling danspratling added Hacktoberfest Hacktoberfest eligible and removed needs more info Further information from author is requested labels Oct 1, 2020
@Being-Maverick
Copy link
Contributor

Hey @danspratling and @jackdomleo7 , I would like to resolve this issue. Please assign it to me.

@Lewiscowles1986
Copy link
Contributor

I am so sorry for tagging this. It was a mistake #73 does not address this in any way

@jackdomleo7
Copy link
Owner

I merged #43 into branch valid_input_and_label and did a little more work.

It was throwing a false error for:

<label>
  Label
  <input />
</label>

And I don't think name is required on an <input>. It's only required if you want to send data to the server.

Either needs a lot more thought or accept we can't do it with CSS.

@jackdomleo7 jackdomleo7 added needs more info Further information from author is requested and removed Hacktoberfest Hacktoberfest eligible good first issue Good for newcomers labels Nov 12, 2020
@jackdomleo7
Copy link
Owner

⚠ For anyone interested in re-picking this up, please refer to the valid_input_and_label branch where work on this has already begun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y feature New feature or request for an a11y check needs more info Further information from author is requested
Projects
None yet
4 participants