browser icon indicating copy to clipboard operation
browser copied to clipboard

UX: Form field markup bug

Open ikbensiep opened this issue 3 years ago • 1 comments

Currently, selecting a form control can only be done by clicking or focusing the form control element itself; focusing the associated <label> element does nothing. This is particularly annoying for radio and checkbox inputs.

The <label> tags do have for='...' attributes, but the form controls all lack an id='...' attribute. (they are outfitted with name='...' attributes, but the input needs to have a matching id attribute for it to respond to a click on its <label> element. :cry: )

Suggested solution

add id attribute matching the name attribute on Form controls (<input>, <select>, <textarea> etc)

ikbensiep avatar Aug 24 '22 15:08 ikbensiep

Probably a good usecase for useId:

https://reactjs.org/docs/hooks-reference.html#useid

evert avatar Aug 24 '22 19:08 evert