ariaLabelFor OR ariaLabeled by in union with Label Component
Priorities and help requested (not applicable if asking question):
Are you willing to submit a PR to fix? Maybe?
Requested priority: Normal
Products/sites affected: SharePoint
Describe the issue:
Unable to connect Labels to fields to be used as the arialabels.
Actual behavior:
Label exists separate from a field.
Current workaround is to duplicate the label information inside the ariaLabel field.
Expected behavior:
Label would have identifiy ID, or the Component associated would have an ID that the Label could use to connect for screenreaders either by ariaLabeledBy or ariaLabelFor.
Hi @JReames, can you provide an example for how you are using the <Label> component? According to implementation we pass through both id and htmlFor attribute that can be used for linking label. So, you got two options:
- Provide
idfor label and usearia-labelledbyon the control that you need to link the label: eg.
<Label id={"mylabelid"}>
label text
</Label>
<Component aria-labelledby={"mylabelid"} />
OR
2. Provide id for another div/component and use htmlFor on label (htmlFor is same as html native for). It takes care of both label linking and shifting focus to control if label is clicked.
<Label htmlFor={"mycomponentId"}>
label text
</Label>
<Component id={"mycomponentId"} />
Hope this helps.
Closing because no response. Please reopen if any issues remain