Consistency and documentation around labelling of form fields
Code of conduct
- [X] I agree to follow this project's code of conduct.
Description of issue
There seems to be different techniques which must be used to label different types of fields. There seems to be inconsistencies in these techniques. Examples
-
sp-pickerhas to be labelled using an associatedsp-field-label. The documentedlabelattribute doesn't seem to work to label the field -
sp-textfield& some others can be labelled using either an associatedsp-field-labelorlabelattribute but I can't find documentation as to the intended behaviour if both are present (sp-field-labelcurrently wins - I thinklabelshould probably win) - I can't find a list of all the field types that
sp-field-labelworks with. Some types it works with partially (i.e. it moves focus but doesn't label egsp-sliderbut others it labels but doesn't move focus (i.e. a native input type=checkbox)
For any component which can be labelled there should be a consistent and reliable method to determine how this labelling should be performed.
Specifically sp-field-label states:
An
provides accessible labelling for form elements. Use the for attribute to outline the id of an element in the same DOM tree to which it should associate itself.
Currently this seems to work for /some/ form elements but not all form elements. It should be clarified which form elements are compatible and which are not.
Thank you James! We're tracking this work in SWC-772 now if you want status updates.