spectrum-web-components icon indicating copy to clipboard operation
spectrum-web-components copied to clipboard

Consistency and documentation around labelling of form fields

Open jnurthen opened this issue 2 years ago • 1 comments

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-picker has to be labelled using an associated sp-field-label. The documented label attribute doesn't seem to work to label the field
  • sp-textfield & some others can be labelled using either an associated sp-field-label or label attribute but I can't find documentation as to the intended behaviour if both are present (sp-field-label currently wins - I think label should probably win)
  • I can't find a list of all the field types that sp-field-label works with. Some types it works with partially (i.e. it moves focus but doesn't label eg sp-slider but 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.

jnurthen avatar May 23 '23 01:05 jnurthen

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.

jnurthen avatar May 24 '23 01:05 jnurthen

Thank you James! We're tracking this work in SWC-772 now if you want status updates.

castastrophe avatar May 07 '25 16:05 castastrophe