-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(icon): remove automatic aria labelling and add a11y guidance #4665
Conversation
src/lib/icon/icon.md
Outdated
the icon is used. | ||
|
||
In thinking about accessibility, it is useful to place icon use into one of three categories: | ||
1. **Decorative**: the icon conveys no real semantic meaning and is purely cosmetic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since all 3 of these cases ask the user to add aria-hidden="true"
, can we just do that for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to always add aria-hidden
, because the failure mode is that something that should be visible to screen reader users isn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can check for a user-added aria-label
, aria-labeledby
, or role
attribute and in those cases we wouldn't set aria-hidden, but if they don't provide any useful description anyways I think its safe to leave it hidden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to mark as aria-hidden
by default based on feedback from Rob Dodson
* The parent `<button>` or `<a>` should either have a meaningful label provided either through | ||
direct text content, `aria-label`, or `aria-labelledby`. | ||
|
||
#### Indicator icons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make this easier we could add a simple component like this (it could also automatically add a tooltip):
<md-indicator [message]="msg">
<md-icon>error</md-icon>
</md-indicator>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that this would be useful. Out of scope for this PR, but maybe add eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, created an issue to track
fb83a63
to
976e294
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Needs rebase |
The automatic application of aria-label for md-icon, in hindsight, was not a great idea. Neither the ligature string nor the SVG filename are likely to be meaningful descriptions. Even in cases where they *are*, the icon may be used in such a way that the application of a label is still the wrong thing. On top of that, adding `role="img"` is usually not the right approach for an icon, as that role typically refers to *content* images, rather than icons that are part of the UI. Ultimately, it is up to the application developer to add the appropriate meaning for icons based on how they're used. To this end, we add guidance to the documentation for what to do in different situations.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The automatic application of aria-label for md-icon, in hindsight, was
not a great idea. Neither the ligature string nor the SVG filename are
likely to be meaningful descriptions. Even in cases where they are,
the icon may be used in such a way that the application of a label is
still the wrong thing. On top of that, adding
role="img"
is usuallynot the right approach for an icon, as that role typically refers to
content images, rather than icons that are part of the UI.
Ultimately, it is up to the application developer to add the appropriate
meaning for icons based on how they're used. To this end, we add
guidance to the documentation for what to do in different situations.