material-components-web icon indicating copy to clipboard operation
material-components-web copied to clipboard

[mdc-switch] add required aria-checked

Open kvdheuvel opened this issue 7 years ago • 3 comments

Feature Request

The current mdc-switch component uses role='switch' but not the required aria attribute aria-checked as described by MDN:

The aria-checked attribute is required when using the switch role, as it represents the current state of the widget that the switch role is applied to. A value of true represents the "on" state; false represents the "off" state; a value of mixed is not supported by the switch role, and is treated as false. The default value is false.

Proposed solution

add aria-checked to the mdc-switch component

Alternatives considered

/

Additional context

Noticed this issue while searching for accessibility issues on our current projects. Everything else works as expected

kvdheuvel avatar Oct 25 '19 07:10 kvdheuvel

Hi,

Thank you for your suggestion. I'm assuming you are referring to updating the README for switch to include aria-checked in the listed templates? (Since the aria-checked attribute is already present in the demo: https://material-components.github.io/material-components-web-catalog/#/component/switch)

Please feel free to submit a pull request to update the docs accordingly!

allan-chen avatar Oct 31 '19 23:10 allan-chen

Hey,

Yes, i'm talking about the README files. I (and i guess most people) use the codes snippets presented in the README docs.

I'll go read the pull-request documentation and give it a try.

kvdheuvel avatar Nov 01 '19 12:11 kvdheuvel

Looks like the logic is missing from the component itself - the catalog's react component wrapping hides this issue. The above pull request should address this.

allan-chen avatar Dec 18 '19 21:12 allan-chen