[SvgIcon] `titleAccess` prop not working properly in conjunction with`component` prop
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
When I use the SvgIcon with component prop like:
<SvgIcon
component={MySvgIcon}
titleAccess="My title"
/>
the aria-hidden="true" is removed and role="img" added, but there is no <title>My title</title> tag added to the svg
Expected behavior 🤔
titleAccess prop should add the <title>my title here</title> tag to the SVG element.
Steps to reproduce 🕹
Steps:
- Import custom SVG icon using webpack
svgrplugin as ReactComponent"
import { ReactComponent as StarIcon } from './star.svg';
- Use the imported SVG in the
componentprop inSvgIconcomponent withtitleAccess
<SvgIcon
component={StarIcon}
titleAccess="My title"
/>
Context 🔦
I want to use my custom SVG icons with the Material UI SvgIcon component and make it fully accessible.
Your environment 🌎
System:
OS: macOS 12.4
Binaries:
Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v16.14.0/bin/yarn
npm: 8.10.0 - ~/work/PWA-Framework/node_modules/.bin/npm
Browsers:
Chrome: 103.0.5060.114
Edge: Not Found
Firefox: 98.0.2
Safari: 15.5
npmPackages:
@emotion/styled: 10.3.0
@types/react: 18.0.1 => 18.0.1
react: 18.0.0 => 18.0.0
react-dom: 18.0.0 => 18.0.0
styled-components: 5.3.5 => 5.3.5
typescript: 4.4 => 4.4.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the SvgIcon component's handling of titleAccess and the component prop, then reproduce the case with a custom ReactComponent imported from star.svg. Done means the rendered SVG includes a <title>My title</title> while retaining the expected accessible role and aria behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- accessibility, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100