fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

ariaLabelFor OR ariaLabeled by in union with Label Component

Open JReames opened this issue 9 years ago • 2 comments

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.

JReames avatar Sep 07 '17 17:09 JReames

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:

  1. Provide id for label and use aria-labelledby on 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.

mdahamiwal avatar Sep 08 '17 10:09 mdahamiwal

Closing because no response. Please reopen if any issues remain

erichdev avatar Oct 19 '17 01:10 erichdev