svg-inline-loader icon indicating copy to clipboard operation
svg-inline-loader copied to clipboard

Apply idPrefix to references in aria-labelledby

Open trotzig opened this issue 7 years ago • 2 comments

To make svgs more accessible to people with screen readers, we can make use of a few elements and attributes:

  • <title> to set a title for the image
  • <desc> to describe the image
  • @aria-labelledby to tell screen readers where the title and description are located in the tree

Here's some more info on how to best use them: https://css-tricks.com/accessible-svgs/#article-header-id-6

We're using svg-inline-loader over at brigade.com to make sure every svg has unique ids, but after adding accessibility markup we noticed that the references weren't right:

<svg viewBox="0 0 24 24" role="img" aria-labelledby="shareIconTitle shareIconDesc">

Share IconPaper airline silhouette.

(I've manually removed some stuff from the above svg to make it shorter).

Notice how the references in aria-labelledby are now referencing missing ids. To fix this, we can apply the prefix here as well.


Apart from the above fix, I modified an assertion made in tests to be more robust.

trotzig avatar Sep 11 '17 12:09 trotzig

CLA assistant check
All committers have signed the CLA.

jsf-clabot avatar Sep 11 '17 12:09 jsf-clabot

Test failures seem unrelated to my changes (they work locally).

trotzig avatar Sep 11 '17 12:09 trotzig