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

Icon - aria-hidden="true" applied when as="a" is specified #2652

Closed
jacknevitt opened this issue Mar 16, 2018 · 7 comments
Closed

Icon - aria-hidden="true" applied when as="a" is specified #2652

jacknevitt opened this issue Mar 16, 2018 · 7 comments

Comments

@jacknevitt
Copy link

Steps

<Icon
  name="point"
  as="a"
/>

OR

<Icon
  name="point"
  as="a"
  aria-hidden={false}
/>
<Icon
  name="point"
  as="a"
  aria-hidden="false"
/>

Expected Result

<a
  class="point icon"
>
</a>

Actual Result

<a
  aria-hidden="true"
  class="point icon"
>
</a>

Version

0.78.3

Testcase

https://codesandbox.io/s/qq2vr3x2qj

@fracmak
Copy link
Member

fracmak commented Mar 16, 2018

This is an interesting problem, because there's no text content related to icons, they should be hidden, even if they are an anchor. What would probably be better is not to show aria-hidden if an aria-label is applied to the icon.

@jacknevitt
Copy link
Author

I have recently learned that assistive technologies rely on aria attributes to explain to impaired users what the element does. As an anchor with no content used for an icon, an aria-label can be used to describe the link. Even with an aria-label, the aria-hidden is still true.
The attribute link can be applied but the icon still renders as an which provides no context to assistive technologies

@jacknevitt
Copy link
Author

On mobile, sorry. *Renders as an <i>

@levithomason
Copy link
Member

Looks like there is consensus on:

What would probably be better is not to show aria-hidden if an aria-label is applied to the icon.

PRs welcome!

@JakobJingleheimer
Copy link

JakobJingleheimer commented Mar 19, 2018

I was actually coming to file an issue requesting a way to provide aria-label for icons so that they are not invisible to the blind, since they have real meaning. However, if aria-hidden is applied statically, it will not work.

I understand that i18n will need to be considered: We use react-intl, so we would want to do something like:

<Icon
    label={formatMessage({ id: 'icon.email' })}
    name="at"
/>

Yields

<i
    aria-label="email"
    class="icon at"
    title="email" // might as well help the sighted too whilst we're at it
></i>

@benbakhar
Copy link
Contributor

Hey, would love to offer my help here. Just to make sure i understand the expected behaviour, the 'aria-hidden="true"' attribute should be applied unless aria-label attribute was passed.

@fracmak
Copy link
Member

fracmak commented Mar 20, 2018

@benbakhar correct, I'm hesitant to recommend the label="" route because other components explicitly use aria-label and we should be consistent. It's also good documentation to place aria-label on a component so people reading it know what it's doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants