-
-
Notifications
You must be signed in to change notification settings - Fork 365
[Icons] Set aria-hidden="true" when title/label not set #1690
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
Conversation
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.
Why instead of an aria-hidden attribute not fill the aria-label with the name from the metadata ?
I don't remember precisely where, but i posted some links about it in the original issue discussion... aria-hidden is really the best thing to do when an icon is used with a label (like the green "open" badge on top of this screen) But your solution could absolutely be something to consider (that's why i'm inclined to keep the configuration, there are so many use cases i'd rather no "force" things for users that don't want some attributes.... or have very good reasons to not want 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.
Thank you @smnandre for taking this!
so in the end no special label
attribute accepted? I'm fine with the title
one only, just curious
Ok for you @WebMamba ? |
Hum no 😁 I don't think it should be a configuration, it should be a behavior that can be overwrite directly when you use the component. And we should document it |
So people would need to add "aria-hidden: false" for all their icons ? That's a niche use case, so why not yes |
Is
I think this should be the default behaviour for the reasons discussed in #1629 but I want to hear your hesitation @WebMamba. Is there an alternate way we can achieve? My thought for this was adding to the |
Yep that was my reasoning to not implement this in the end. I don't want to confuse users with non-existing svg attributes. |
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.
Thanks @smnandre! This DX looks good! Sorry to ask you to rewrite all the tests 😁
if ([] === array_intersect(['aria-hidden', 'aria-label', 'aria-labelledby', 'title'], array_keys($attributes))) { | ||
$iconAttributes['aria-hidden'] = 'true'; | ||
} | ||
if ([] === array_intersect(['aria-hidden', 'aria-label', 'aria-labelledby', 'title'], array_keys($attributes))) { |
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.
simple curiosity where did you get this list?
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.
An image’s alt attribute.
A SVG’s child title element.
Using aria-label or aria-labelledby on an image or SVG.
Using a title attribute on an image or SVG.
https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
f50f456
to
36600e3
Compare
Thanks Simon. |
Add "aria-hidden=true" when the icon has no title, aria-label or aria-labelledby attribute
(option enabled per default)