Icon: Doesn't consume 'aria-labelledby' from ImageProps
Environment Information
- Package version(s): 7.18.1
- Browser and OS versions: N.A.
Please provide a reproduction of the bug in a codepen:
https://codepen.io/anon/pen/xvdEPY
Actual behavior:
Nothing.
Expected behavior:
aria-labelledby - and similar HTML attributes - in imageProps should be applied to the Icon's <i> element.
Priorities and help requested:
Are you willing to submit a PR to fix? No
Requested priority: Normal; potentially an accessibility issue
Products/sites affected: N.A.
Hi @HalcyonPride thanks for submitting this and referencing the codePen example! I was able to repro this and will work on getting it fixed.
Noticed this issue since I'm also working on some Icon changes (#9884). I'm not sure that hoisting aria-* attributes from imageProps to the icon root makes sense. If you want those attributes applied to the root, you can apply them there directly (see https://codepen.io/ecraig12345/pen/WNewvMd?editors=0010). Is there a case where you're not able to apply the attributes to the root for some reason?
@ecraig12345, I can't say - I'm just basing my comments off what's already written in Icon.base.tsx:

All that's doing is determining whether the container should be aria-hidden based on the provided imageProps. It's not directly passing any props through.
Yes, but it's implying that aria-labelledby etc. is passed via imageProps. Otherwise, why is it trying to read those attributes from imageProps?
Conversely, this code needs to be updated if we expect aria-* attributes to be passed via the icon root instead.
Hmm. I am seeing aria attributes passed through. If aria-labelledby is passed into imageProps would fall to the img element. https://codepen.io/dzearing/pen/KKPeVQe?editors=1011
If you need the aria-labelledby to live on the container div, you could apply the attribute on the Icon itself:
<Icon
iconName="upload"
className="ms-IconExample"
aria-labelledby='on the i'
imageProps={ {
src: 'https://www.fillmurray.com/100/100',
'aria-labelledby': "on the img"
} }
/>
But I think the aria-hidden logic certainly adds some confusion.
I'm not totally familiar with this area; it seems like we should focus the aria attributes in one place; sticking them on the container makes sense, and at a minimum for aria-hidden logic above, reading them from there and falling back to current behavior would make more sense.
So proposal would be:
Adjust the aria-hidden calculation to first pull labelled-by from the root.
Thoughts?
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!
@dzearing, that sounds good to me 😊 thanks for the feedback! @leddie24, could you please revise your code per David's proposal?
:tada:This issue was addressed in #10526, which has now been successfully released as @uifabric/[email protected].:tada:
Handy links:
:tada:This issue was addressed in #10526, which has now been successfully released as @uifabric/[email protected].:tada:
Handy links:
:tada:This issue was addressed in #10526, which has now been successfully released as [email protected].:tada:
Handy links: