-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Default role="img" introduced in #737 #750 is a breaking change and should be reverted/have opt-out #788
Comments
Looks like my syntax was slightly wrong for how to pass svgProps: { role: "{undefined}" }, Just FYI for anyone who wants the old behavior. I still think this shouldn't be the default, but would suggest if its kept this way that it's explicitly documented what that means for accessibility (labels required on the SVGs) as well as the specific override to get the old behavior? |
@gregberge I should have time to raise a PR this week. I'm thinking back out the changes then add an accessibility section to the documentation and show how to override it with |
🐛 Bug Report
Default role="img" introduced in #737 #750 is a breaking change and should be reverted/have opt-out.
Not a huge fan of this being defaulted in the way it was. While I appreciate the sentiment this is problematic since now this requires alt text/aria-labels or a role="presentational" override on every SVG output from SVGR (to my understanding, I could be wrong that a label would be required now - https://dequeuniversity.com/rules/axe/4.4/svg-img-alt?application=axeAPI).
Most of our usages of SVGs are for icons used in buttons that already configured for accessibility and the SVG doesn't need to be focusable or explained to the non visual user.
It would at the least be nice if we could opt-out of this default behavior, I noticed we do parse the
svgProps
but since that's a spread/merge it wont override if we set role toundefined
to attempt to unset it.In addition with further research seems like SVGs really shouldn't have their implict role blanket overridden with
img
as it is: https://www.unimelb.edu.au/accessibility/techniques/accessible-svgs#:~:text=SVG%20Roles,%3D%22graphics%2Dsymbol%22.To Reproduce
Steps to reproduce the behavior:
@svgr/rollup >= 6.4.x, can view new role in snapshots
Expected behavior
A clear and concise description of what you expected to happen.
No default configuration for the
role
on SVG, if folks need that behavior they can already pass it in with the existingsvgProps
on the configuration. Or a way to opt out of this new behaviorLink to repl or repo (highly encouraged)
Please provide a minimal repository on GitHub.
Issues without a reproduction link are likely to stall.
Run
npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard
Paste the results here:
The text was updated successfully, but these errors were encountered: