-
Notifications
You must be signed in to change notification settings - Fork 70
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
HTML labels not bound to their form elements #325
Comments
I am aware of this. To be able to bind them to the input field they would have to go after it.
I never adopted this as it requires some nasty CSS to get the label above the field. Like margin-top: -2em. If there is a better approach we can consider adopting this for 3.0. But it has to be clean and simple. Edit: I am speed reading, and it's possible I misunderstood you. You would like to address the input fields from their labels by click, yes? Like |
Yes you did misunderstand at a glance, I meant That would look like this:
My intention here is to make LiteCart more accessible. Not only does this make the text "Company" clickable to add focus to the input for company, it also helps accessibility screen readers convey to the visually-impaired that this is the input for company. I've added a screen reader to my Chrome so I can test it. |
This is one way of doing it. But as label is natively an inline element, it feels wrong to use it as a block.
|
Hey brother, that works for the instances of input="checkbox", but few others instance because of the divs, yes. I have a commit for you, delayed because I'm going through my modifications line by line making sure I don't overwrite any of your changes from my current working version and the one you're modifying at the moment. Commit coming soon. |
It works for any input, select or textarea. I want to avoid having to set ids for each and every field and label. |
Here is a universal way using javascript I came up with. Not tested, may contain an error or two.
|
Description
Hi, I forked the repository and will be submitting a commit for this issue soon. There are two options to resolve this issue, either wrap the form element in the
<label>
, or add a for attribute to the<label>
and an id to the form element it should be bound to.At a glance, you'd think wrapping the form element in the
<label>
would be the way to go, but that requires all the nested elements to be inline (i.e., no nested<div>
s). So I've been adding for attributes and ids. Doing it this way avoids the nested block-level issue but doesn't include the fonticon in the<label>
, so my solution there is to wrap the fonticons in their own<label>
. It's perfectly fine to have multiple<label>
s pointing to the same form element's id.From what I can tell, only the email, password and remember me form elements are in duplicate on a given page, so I assigned topEmail, sideEmail and email as their ids, and the same for password and remember me, respectively. Does anyone know if there are any other duplicate element names used in the admin forms? I haven't gotten to those yet.
I have more modifications coming btw, namely WAI-ARIA. I'll be adding that in a subsequent commit.
LiteCart Version
2.5.4
PHP Version
8.1
Error/Backtrace
No response
Is this a problem that can be reproduced in the demo platform?
None
If this problem could be related to a browser. Which one?
None
The text was updated successfully, but these errors were encountered: