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

Fix accessibility of examples buttons #37498

Merged
merged 2 commits into from
Nov 17, 2022

Conversation

MewenLeHo
Copy link
Contributor

@MewenLeHo MewenLeHo commented Nov 15, 2022

Description

Fix accessibility of 'Try it on StackBlitz' and 'Copy to clipboard' buttons.

Motivation & Context

Svgs inside 'Try it on StackBlitz' and 'Copy to clipboard' buttons are pure decoration so they must be ignored by any assistive technology.

See https://www.w3.org/TR/WCAG21/#non-text-content for more details.

Type of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

@MewenLeHo
Copy link
Contributor Author

I am also currently wondering if adding focusable="false" to the <svg> elements could be useful since it may cause an accessibility issue in Internet Explorer?

@patrickhlauke
Copy link
Member

title technically provides an accessible description, rather than an accessible name.

maybe a slicker way around it is to add aria-label to the <button> - then you can save yourself the aria-hidden="true" on the internal svg as well, since the aria-label on the parent will completely replace/override whatever's inside the button anyway?

<button ... aria-label="Try" title="Try it on StackBlitz">
  <svg class="bi"><use xlink:href="#lightning-charge-fill"/></svg>
</button>

as for focusable="false", not sure if we still need to cater to IE since it's now been officially deprecated by Microsoft, and that was the only browser exhibiting this odd behaviour.

Copy link
Member

@patrickhlauke patrickhlauke left a comment

Choose a reason for hiding this comment

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

See comment about adding the aria-label to the <button> and removing the aria-hidden as well

@patrickhlauke
Copy link
Member

also, note that

Svgs inside 'Try it on StackBlitz' and 'Copy to clipboard' buttons are pure decoration so they must be ignored by any assistive technology.

is perhaps not completely accurate. They're not pure decoration, they represent the content/label of the button... but that's probably splitting hairs

@MewenLeHo
Copy link
Contributor Author

<button ... aria-label="Try" title="Try it on StackBlitz">
  <svg class="bi"><use xlink:href="#lightning-charge-fill"/></svg>
</button>

Ok with your version and for your opinion about focusable="false" since IE is not listed anymore in the list of supported browsers on .browserslistrc file

However I think it will be better to keep the same content in the two attributes:

<button ... aria-label="Try it on StackBlitz" title="Try it on StackBlitz">
  <svg class="bi"><use xlink:href="#lightning-charge-fill"/></svg>
</button>

@patrickhlauke
Copy link
Member

depending on browser/assistive technology used, both the accessible name and description may be announced, resulting in an overly verbose announcement (though, at least with Chrome/NVDA and Chrome/Jaws, it seems that if both are exactly the same, it's only announced once). Will test some more later just to check...

@patrickhlauke
Copy link
Member

title technically provides an accessible description, rather than an accessible name.

I've actually just tested it, and it seems that consistently browsers use/expose title as an accessible name if it's the only thing present, rather than using it as a description

Long story short, after more testing (also in Firefox/Win and Safari/macOS), ignore my suggestion. This will be fine as is ;)

@patrickhlauke
Copy link
Member

also, i'd note that those buttons were accessible even before this, but they did lead to an unnecessarily verbose announcement (along the lines of "image Try it, button, Try it on StackBlitz"). so this PR is more of a nice tweak ("Try it on StackBlitz, button")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants