docusaurus: a11y: light & dark mode checkbox doesn't announce state switches

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Following up from #6665: The color mode toggle now does correctly indicate what its state is with its label. But, when you activate it while using a screenreader, nothing narrates that it switched.

Discussed on stream with @BenDMyers on Twitch: https://www.twitch.tv/videos/1498962341.

Reproducible demo

https://typescript-eslint.io

Steps to reproduce

  1. Activate a screenreader such as NVDA or VoiceOver
  2. <kbd>Tab</kdb> over to the light/dark mode toggle
  3. Press <kbd>Enter</kbd> to trigger it

Expected behavior

There should be a narration, such as what’s provided by aria-pressed.

See more here: https://sarahmhigley.com/writing/playing-with-state

Actual behavior

No narration.

Your environment

Self-service

  • I’d be willing to fix this bug myself.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (5 by maintainers)

Commits related to this issue

Most upvoted comments

A JS-less accessible tooltip would definitely be an improvement.

I can’t suggest swapping aria-label and title, I was just sharing that information so you were clear on which aspects of the UX each controlled in this scenario.

Some usability testing with disabled folks would be a great way to hone the control, but I know that’s probably not realistic in this case. I’d point you towards some public usability data for this type of control, but I’m unfortunately not aware of any. It seems like an emerging UI pattern, a tri-state icon button to control light/dark theme. I’m struggling to think of where I’ve seen other tri-state buttons on the web.