Environment
All versions
Reproduction link
https://www.iviewui.com/components/form-en
Steps to reproduce
Click on a label
What is expected?
Input related to said label should get focus
What is actually happening?
Nothing
As per WCAG 2.0 H44:
https://www.w3.org/TR/WCAG20-TECHS/H44.html
An additional benefit of this technique is a larger clickable area for the control, since clicking on the label or the control will activate the control. This can be helpful for users with impaired motor control.
Examples of standard HTML elements, including how to achieve this:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
1条答案
按热度按时间8fsztsew1#
I could try implementing this. But the question is what option to go for:
for="theGeneratedId"
for the label. (Horrible option)span
and wrap theinput
+span
into alabel
element. Basically changing thediv.ivu-form-item
into alabel
element and changing thelabel.ivu-form-item-label
into aspan
element. (This alone fixes the issue without any JS and is valid syntax)label
element that sets focus to the input. (Not a bad solution but kind of hackish?)label-for
prop. It works, but when you are using FormItem with a label, I think it is a fair assumption that the library should handle linking the label to the input.In option 2, the required changes would be:
.ivu-form-item { display: block }