Skip to content
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

Ensure alt attribute in custom icon img elements #3245

Merged

Conversation

MichaelMarcialis
Copy link
Contributor

@MichaelMarcialis MichaelMarcialis commented Apr 3, 2020

Summary

This PR fixes the img element in EuiIcon components using custom SVGs to have an alt attribute with an empty string, rather than no alt attribute at all. This ensures validation while also indicating to screen readers to not read icons that are for decoration purposes only.

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation examples
- [ ] Added or updated jest tests
- [ ] Checked for breaking changes and labeled appropriately

  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@MichaelMarcialis MichaelMarcialis marked this pull request as ready for review April 3, 2020 15:18
@chandlerprall chandlerprall requested review from myasonik and removed request for myasonik April 3, 2020 15:35
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3245/

@cchaos cchaos requested review from miukimiu and removed request for cchaos April 3, 2020 15:43
@myasonik
Copy link
Contributor

myasonik commented Apr 3, 2020

I'm on the fence about approving this.

On one hand, this does work... On the other hand, I don't know if I trust devs to remember to pass in a value for title even if the icon has meaning.

The way it currently stands, pages will fail automated testing when/if that's the case and the images can be triaged. (Assuming that devs are doing automated testing...) That can be annoying but should be a one time cost. For Kibana as an example, as the automated testing gets broader and broader it should also stop these things from ever even being merged in the first place.

With this change, all images will appear to pass automated testing but false negatives are incredibly difficult to spot...

Can someone convince me one way or the other?

@miukimiu
Copy link
Contributor

miukimiu commented Apr 3, 2020

When the icons are rendered as SVGs if no title is provided they get an aria-hidden=true. So we assume it's for decoration purposes only.

We also have this EuiCallOut on top of the page to ensure devs pass a title:

Screenshot 2020-04-03 at 17 17 06

For me, it makes sense the alt attribute with an empty string for icons rendered as img. So they will behave as decorative images same way the rendered SVGs are.

I think it will always be difficult to track false negatives. So we have to assume devs are going to follow the best practices we recommend in the docs.

But @myasonik I think you're the right person to make a decision here.

Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miukimiu You convinced me by saying this would bring it inline with how svgs are currently handled. At least it'll be consistent 😅

🚀

Copy link
Contributor

@miukimiu miukimiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@MichaelMarcialis MichaelMarcialis merged commit 8dfb4f9 into elastic:master Apr 3, 2020
@MichaelMarcialis MichaelMarcialis deleted the bug/icon-img-alt-attr branch April 3, 2020 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants