-
Notifications
You must be signed in to change notification settings - Fork 934
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
Add more resilience to decorative SVGs #3892
Conversation
| - name: report | ||
| meta: "exlamation danger stop" | ||
| meta: "exclamation danger stop" |
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.
Doh!
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.
This looks good to me. Do you want to update the SVGs in https://github.com/uswds/uswds/blob/develop/src/components/icons/icons--sizes.njk to include focusable="false"?
|
Mmm, yes I can do that. |
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 should move the focusable attribute to <span class="icon-lock">.
Sidenote
I'm not sure if it's a blink/webkit thing, but I had trouble tabbing to the banner contents on the latest chromium version of Edge.
|
Oh, there's also the icon list too! |
Use the
aria-hidden="true"property on decorative images (<img>) whose source is an SVG.Adding
role="img"fixes a webkit bug that causes images with an SVG source be be announced as a group, not an image. However, addingrole="img"andalt=""result in an object that's selectable by AT but not announced (at least in our testing on VoiceOver and Chrome). Addingaria-hidden="true"results in a properly hidden element.Adding
aria-hidden="true"only would be equally effective (it rendersrole="img"moot) but we choose to add all three to be as consistent as possible with<img>, even if it is redundant. Thus, each of the following can always be true for<img>:alt=""for decorative imagerole="img"for images with an SVG sourcearia-hidden="true"for decorative images with an SVG sourceAdd
focusable="false"to<svg>elements meant to be images (ie not text/data).This prevents an IE11 bug that could allow the
Tabkey to navigate into the SVG.For decorative SVGs, use
role="img"andaria-hidden="true"as above. Using both allows us the following consistent rules for the<svg>element:role="img"andfocusable="false"for SVGs meant to be images (ie don't contain text/data)aria-hidden="true"for decorative SVGsaria-label="[accessible name]"oraria-labelledby="[id list]"for SVGs that convey information and need an accessible descriptionSource: https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html