question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Icon should add an identifier to the <svg> element indicating which icon

See original GitHub issue

I was working on implementing react-testing-library in relax, and was following a few of the patterns from @jxnblk 's PR: https://github.com/pricelinelabs/design-system/pull/407/files#diff-76b0baeaa20dde93defea3ea13eb463eR108

One thing that is missing on the svg rendered by the <Icon> component is a title attribute or some other indicator of what icon it is. This probably also has accessibility concerns, but the primary use case I’m referring to is something like this:

const icon = container.querySelector('svg')
expect(icon).toBeTruthy()

It would be helpful to be able to verify that the icon rendered is the correct one when writing react-testing-library tests.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jxnblkcommented, Jan 11, 2019

Yeah, I think for a11y that “decorative” icons should have the aria-hidden attribute and icons with meaning can use the <title> tag – not sure how we’ll want to handle that, but we should do some research to make sure we handle this in a good way

Read more comments on GitHub >

github_iconTop Results From Across the Web

How SVG Fragment Identifiers Work - CSS-Tricks
I just wanna stack the icons on top of each other. If the icons all have the same viewBox and you essentially just...
Read more >
Let's Talk SVG Icons: Why and How to Use (and Create) Them
We'll tell you why we love using SVG icons (yes, more than icon fonts!). Plus, learn how to create and style SVG icons...
Read more >
onfido/castor-icons - GitHub
When referring to a fragment identifier for an icon to be used, a link is made to icons.svg sprite through the <use> element....
Read more >
Introduction – SVG 1.1 (Second Edition) - W3C
An SVG context is a document fragment where all elements within the fragment must be subject to processing by an SVG user agent...
Read more >
SVG not showing up with use xlink, only with img src
If you want to use a <use> element and have it work with today's ... <svg> root element and have a fragment identifier...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found