Skip to content

Fix code-language-switch a11y lighthouse audit #1247

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

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

AndrewJakubowicz
Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz commented Nov 1, 2023

Context

The code language switch was triggering the following audit issue: https://dequeuniversity.com/rules/axe/4.7/label-content-name-mismatch

Basically it wanted the aria-label to contain JS TS within it. This didn't make much sense to me, so I looked up the switch accessibility pattern https://www.w3.org/WAI/ARIA/apg/patterns/switch/

Fix

Use the same accessibility pattern as https://www.w3.org/WAI/ARIA/apg/patterns/switch/examples/switch-button/ and hide the inner text content. This prevents redundant announcement of state by screen readers.

We can hide the JS and TS text from the accessibility tree as our switch already provides full information via aria-label, and aria-checked. This then passes the audit because we no longer need to include the string JS TS in the aria label.

Testing

Tested by looking at the accessibility tree developer console. The switch has the label Toggle TypeScript, and checked state of true or false.

Lighthouse audit is now passing for this component.

Copy link

github-actions bot commented Nov 1, 2023

A live preview of this PR will be available at the URL(s) below.
The latest URL will be appended to this comment on each push.
Each build takes ~5-10 minutes, and will 404 until finished.

https://pr1247-feefe04---lit-dev-5ftespv5na-uc.a.run.app/

@AndrewJakubowicz AndrewJakubowicz merged commit 06ddf27 into main Nov 1, 2023
@AndrewJakubowicz AndrewJakubowicz deleted the aira-code-language-switch branch November 1, 2023 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants