Icons incorrectly use aria-hidden instead of aria-label, and some lack either
SveinungTorresdal opened this issue ยท 1 comments
When browsing the internet with a screenreader one depends on aria-label
to accurately describe functionality. By contrast, aria-hidden
removes the element from the screenreader's DOM tree, as well as its children. Therefore, it is important that interactive elements are labeled, and especially elements that only use an icon.
The following components use aria-hidden
for its accompanying material icon, even though the button is an interactive element with no other label, or lack aria-hidden
and aria-label
:
- Action Lists - ๐
more-vert
icon should havearia-label
instead ofaria-hidden
- Alerts - โ
close
icon should havearia-label
instead ofaria-hidden
- Dialog - โ
close
icon should havearia-label
instead ofaria-hidden
- Nav - icons-only are
aria-hidden
, should havearia-label
, or change with breakpoint. - Sheet - โ
close
icon should havearia-label
instead ofaria-hidden
. - Sidebar - icons lack
aria-hidden
andaria-label
, should likely usearia-hidden
. - Toast - โ
close
icon is missingaria-hidden
andaria-label
, should havearia-label
. - Tooltips - โ
help_outline
is missingaria-hidden
andaria-label
, should havearia-label
- Topbar - ๐
menu
and โclose
icons should havearia-label
instead ofaria-hidden
.
To Reproduce
Steps to reproduce the behavior:
- Launch Chrome.
- Install ChromeVox.
- Recommended: Enable focus on cursor in the settings.
- Visit the Design Guide with ChromeVox enabled.
- Navigate to the components mentioned and interact with the icon(s).
- Observe lack of speech, or strange speech. Example: Screen readers will read
_
, i.e.help underscore outline
.
Expected behavior
- Purely decorative icons should be
aria-hidden
. - Interactive elements that combine icons and text should always use
aria-hidden
if text is sufficiently descriptive. - Interactive elements that exclusively use icons should always use
aria-label
to describe the function of the element. - All material icons should use either
aria-hidden
oraria-label
.
Actual behavior
As described above, a number of icons use aria-hidden
, or lack both aria-hidden
and aria-label
when one of them should always be present.
Some further discoveries show that rather than aria-label
on the icon we should employ it on the parent element if it is interactive, or use a .sr-only
span element next to it for static, non-interactive content.