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

[SvgIcon] Improve accessibility #12822

Merged
merged 2 commits into from
Sep 10, 2018

Conversation

oliviertassinari
Copy link
Member

Help with #4489 too

@@ -52,6 +52,7 @@ function SvgIcon(props) {
color,
component: Component,
fontSize,
moreChildren,
Copy link
Member Author

Choose a reason for hiding this comment

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

@mbrookes Any idea for a better name?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure - it feels kinda funky having it at all. Does it have any use case besides <desc>? If not, perhaps we should make than an explicit (but optional) prop. Alternatively, could <desc> not be included in children along side the <path>?

Copy link
Member Author

@oliviertassinari oliviertassinari Sep 10, 2018

Choose a reason for hiding this comment

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

The use case if for the icons exposed in @material-ui/icons. There is a use case for title (if people want to add an id), desc, defs and probably more.

Copy link
Member

Choose a reason for hiding this comment

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

Is this use case uncommon enough that we can justify letting users decide whether or not to break the pure() optimisation by passing the elements as children to the icon?

Copy link
Member

@mbrookes mbrookes left a comment

Choose a reason for hiding this comment

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

Nice job!


### Semantic SVG Icons

If your icon has semantic meaning, all you need to do is throw a `titleAccess="meaning"` property. It should be enough but you can always use the `moreChildren` property to add a `desc` description element.
Copy link
Member

Choose a reason for hiding this comment

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

"throw in a"


If your icon has semantic meaning, all you need to do is throw a `titleAccess="meaning"` property. It should be enough but you can always use the `moreChildren` property to add a `desc` description element.

In the case of focusable interactive elements, like when used with a icon button, you can use the `aria-label` property:
Copy link
Member

Choose a reason for hiding this comment

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

"an icon button"


### Semantic Font Icons

If your icons have semantic meaning, you need to provide a text alternative only visible assisitive technologies.
Copy link
Member

Choose a reason for hiding this comment

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

"visible to"

@@ -52,6 +52,7 @@ function SvgIcon(props) {
color,
component: Component,
fontSize,
moreChildren,
Copy link
Member

Choose a reason for hiding this comment

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

Not sure - it feels kinda funky having it at all. Does it have any use case besides <desc>? If not, perhaps we should make than an explicit (but optional) prop. Alternatively, could <desc> not be included in children along side the <path>?

@@ -74,10 +75,12 @@ function SvgIcon(props) {
viewBox={viewBox}
color={nativeColor}
aria-hidden={titleAccess ? 'false' : 'true'}
role="img"
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be role={titleAccess ? 'img' : 'presentation'}

@oliviertassinari oliviertassinari force-pushed the icon-accessibility branch 2 times, most recently from cee7cb2 to f664ca6 Compare September 10, 2018 20:44
@oliviertassinari oliviertassinari dismissed stale reviews from nathanmarks and mbrookes September 10, 2018 20:54

changed

// ...

<Icon>add_circle</Icon>
<span className="sr-only">Create a user</span>
Copy link
Member Author

@oliviertassinari oliviertassinari Sep 10, 2018

Choose a reason for hiding this comment

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

I think that we should add a screanReaderOnly variant to the typography.

@oliviertassinari oliviertassinari merged commit 679c303 into mui:master Sep 10, 2018
@oliviertassinari oliviertassinari deleted the icon-accessibility branch September 10, 2018 21:04
marcelpanse pushed a commit to marcelpanse/material-ui that referenced this pull request Oct 2, 2018
* [SvgIcon] Improve accessibility

* review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: SvgIcon The React component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants