-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(icon): fix aria roles and attributes #10024
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
@ThomasBurleson @nbtorcol I haven't built the unit tests yet since I want ensure this is the proper logic before I do. |
Let me get back to you tomorrow.
|
00a3b37
to
1468ed1
Compare
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
This is better, but it is still not correct. I will try to explain more • Apply img role by default -- yes • Don't change ARIA if it's already valid -- yes • Prioritize alt attribute for aria-label -- yes • Apply presentation role if parent or parent's parent has ARIA label – • Fallback to icon name as an aria label -- yes • Apply presentation role instead of aria-hidden when all checks fail –
|
@nbtorcol I'm sorry I didn't use the code your provided (on the issue page), but that was because it was private link on a Google Drive when I started writing the PR (for future reference, something like pastebin.com would serve better). The use of I believe the reason why we want to use
Which, to my understanding, means If I understand correctly, you suggest we should only perform a parent aria check based on a whitelist of tagNames and/or or ARIA. It would reduce the specificity of our upwards search, but I have no problem implementing it. As for the third point of respecting Edit: Originally my research of aria-label lead me to examples in the ARIA spec related to how to handle labels and images here: https://www.w3.org/TR/wai-aria/roles#presentation and https://www.w3.org/TR/wai-aria/roles#textalternativecomputation |
@nbtorcol <https://github.com/nbtorcol> I'm sorry I didn't use the code
your provided (on the issue page), but that was because it was private link
on a Google Drive when I started writing the PR (for future reference,
something like pastebin.com would serve better).
Apologies, that was partially an oversight on my part. I will look at that
website, but what I use is driven almost entirely by the level of
accessibility. Given that I am doing this as a side project at work, I
don’t have a lot of time to learn new stuff.
The use of presentation=role instead of aria-hidden is from research that
it is more reliable than aria-hidden (especially with IE and JAWS). After
more research, it seems I can safely use both (and even possible tabindex=-1
).
The tabIndex attribute is only relevant for controls and should not be used
with icons.
See: http://john.foliot.ca/aria-hidden/
That article is four years old; both the screen readers and browsers have
changed a lot in that time. Please base your conclusions off of more recent
articles or conduct your own experiments; NVDA is free, and JAWS has a
demo. I can help test if needed and/or point you to relevant articles and
information from people.
If I understand correctly, you suggest we should only perform a parent aria
check based on a whitelist of tagNames and/or or ARIA. It would reduce the
specificity of our upwards search.
Yes.
As for the third point of respecting `aria-hidden, I have added a check for
the mdIcon itself, but I never checked the parent. I will add this to the
code.
Not sure what you mean here; sorry if my prior comments were confusing.
|
@clshortfuse - status update plz ? |
1468ed1
to
738f414
Compare
@nbtorcol I've added the changed we've discussed. I removed I'm a little confused about the whitelisting I feel a blacklist would work better, or else our code will eventually become incompatible when newer versions of the HTML spec and when new ARIA roles are created. |
3bd88be
to
6d2287c
Compare
6d2287c
to
894307f
Compare
I will get the blacklist to you today. I was gone on vacation for a while
and then had a lot to do when I got back.
|
Do you still have access to the Google doc that I made before? I updated
the code there.
|
@nbtorcol Yes, I do have access. I'm updating the PR now. Thank you! |
Sounds good. Please let me know if you have any questions.
|
@nbtorcol I just want to confirm a couple of concerns
Perhaps we should
Also, I would need some clarification about hwo to use the shared role and tag names. |
Oops, number was supposed to not be part of the blacklist. Sorry.
Time, as an HTML tag fails.
Some of the ARIA roles that were included but now blacklisted are because I
ran an actual test with screen readers, and those are the results.
- return false if aria role blacklist fails
- return true if any input type is used
- return false if html tag blacklist fails
Sounds good. In that case, per my code, you can just drop retrieving the
type attribute.
|
bf8b05e
to
bdf6a3e
Compare
@nbtorcol @ThomasBurleson All changes have been made and we are ready for review. |
Do you mean committed?
|
return false; | ||
} | ||
/* Perform role blacklist check */ | ||
if (domElement.attributes.role) { |
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.
@clshortfuse - Please move this to the aria utils. This complexity should not be in the iconDirective.
4bbf420
to
3e5ef8e
Compare
@nbtorcol Generally, we ask another team member to check our work before we commit directly to our master branch @ThomasBurleson I made the changes, as requested. Both functions are now accessible by any component via the $mdAria service. Also, the number of parents searches are based on a passed variable. |
LGTM |
mdIcon was improperly assuming its parent's text content would be announced didn't apply ARIA roles properly icon component: * Apply `img` role by default * Don't change ARIA if it's already valid * Prioritize `alt` attribute for aria-label * Apply `aria-hidden` attr if parent has ARIA level (2 levels deep) * Fallback to icon name as an aria label * Apply `aria-hidden` attr instead of `aria-hidden` when all checks fail * Add spec tests * Remove improper spec test based on text content aria service: * Add hasAriaLabel func to check for valid aria label * Add parentHasAriaLabel func to check parents for valid aria with role and tagName blacklists * Add spec tests Fixes angular#9629
3e5ef8e
to
1b1329c
Compare
mdIcon was improperly assuming its parent's text content would be announced didn't apply ARIA roles properly
img
role by defaultalt
attribute for aria-labelaria-hidden
attr if parent or parent's parent has ARIA label and is not part of role or tagName whitelistaria-hidden
attr instead ofaria-hidden
when all checks failFixes #9629