You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
icon: Providing empty alt or aria-label attributes do not fully hide icon from assistive tech #10721
What is the issue? *
Defining alt="" and aria-label="" on md-icon elements do not fully hide the icon from assistive technology. The documentation states that defining those attributes as empty will put aria-hidden="true" on the element, but this doesn't happen.
What is the expected behavior? *
Defining either (or both) alt="" or aria-label="" should set aria-hidden="true" to the md-icon element. The icon name should not be used as an alternative aria-label if no aria-label is available. By defining aria-hidden="true" this element this will fully hide the element from assistive technology.
CodePen (or steps to reproduce the issue): *
Details: Add aria-label="" to an md-icon with role="img" and/or add alt="" to an md-icon with role="img". Use a screen reader to navigate to the image element - It will be navigable by a screen reader but will have no label.
Still, in master, there's no logic in mdIcon that checks if the attribute exists, only if it is truthy (if (attr.alt)). Performing a hasAttribute check would fix it. Alternatively, a null-check (alt == null) could work as well, though that would include an implicit conversion.
The demo provided still has the issue where providing only an empty alt attribute still creates an aria-label with the inner HTML of the md-icon element. Since the documentation for alt says that "If an empty string is provided, icon will be hidden from accessibility layer", the current implementation will mislead users.
Adding an alt attribute with some label text (and no aria-label) creates an element with both an aria-label and an alt attribute with identical text. This could cause unexpected results with assistive technology.
Why do both aria-label and alt need to be in the documentation? When I tested with Voiceover, the alt attribute isn't read by assistive technology, only the aria-label is. So it is perhaps okay to allow users to provide either an aria-label or an alt attribute, but it should always propogate to an aria-label on the rendered element.
The documentation should not say that empty alt/aria-label hides from the accessibility layer with aria-hidden="true". That's not what's happening here, and could be misleading for developers.
changed the title [-]mdIcon: Providing empty alt or aria-label attributes do not fully hide icon from assistive tech[/-][+]icon: Providing empty alt or aria-label attributes do not fully hide icon from assistive tech[/+]on Jun 8, 2020
Activity
ThomasBurleson commentedon Jun 13, 2017
@katiehockman - do you have a reproducible issue/Plunkr ?
katiehockman commentedon Jun 13, 2017
https://codepen.io/katiehockman/pen/GEjRKz
Thanks!
ThomasBurleson commentedon Jun 13, 2017
@EladBezalel - can you fix this one also?
clshortfuse commentedon Jun 15, 2017
Note that the codepen is testing against 1.1.0.
Still, in master, there's no logic in
mdIconthat checks if the attribute exists, only if it is truthy (if (attr.alt)). Performing a hasAttribute check would fix it. Alternatively, a null-check (alt == null) could work as well, though that would include an implicit conversion.ThomasBurleson commentedon Jun 15, 2017
Here is an updated CodePen using latest/HEAD from AngularJS Material: https://codepen.io/angular-flex-layout/pen/eRBVpX
katiehockman commentedon Jun 26, 2017
The demo provided still has the issue where providing only an empty alt attribute still creates an aria-label with the inner HTML of the md-icon element. Since the documentation for alt says that "If an empty string is provided, icon will be hidden from accessibility layer", the current implementation will mislead users.
For example:
A few other thoughts/issues:
25 remaining items
[-]mdIcon: Providing empty alt or aria-label attributes do not fully hide icon from assistive tech[/-][+]icon: Providing empty alt or aria-label attributes do not fully hide icon from assistive tech[/+]fix(icon): providing empty alt or aria-label attributes do not hide t…
fix(icon): providing empty alt or aria-label attributes do not hide t…