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

The light/dark toggle button does not communicate its state #76

Open
Tracked by #72
gabalafou opened this issue May 28, 2024 · 12 comments · May be fixed by pydata/pydata-sphinx-theme#1924
Open
Tracked by #72

The light/dark toggle button does not communicate its state #76

gabalafou opened this issue May 28, 2024 · 12 comments · May be fixed by pydata/pydata-sphinx-theme#1924
Assignees
Labels

Comments

@gabalafou
Copy link

gabalafou commented May 28, 2024

It communicates it visually but not through the accessibility tree

@gabalafou gabalafou changed the title DEV The light/dark toggle button does not communicate its state The light/dark toggle button does not communicate its state May 28, 2024
@gabalafou gabalafou changed the title The light/dark toggle button does not communicate its state [S] The light/dark toggle button does not communicate its state May 30, 2024
@gabalafou gabalafou added the size: S A few hours, less than one week label May 31, 2024
@gabalafou gabalafou changed the title [S] The light/dark toggle button does not communicate its state The light/dark toggle button does not communicate its state May 31, 2024
@trallard
Copy link
Member

trallard commented Jun 4, 2024

Not sure if we should also address pydata/pydata-sphinx-theme#1491

@Carreau
Copy link

Carreau commented Jun 27, 2024

It communicates it visually but not through the accessibility tree

I'm not sure I completely understand, can you expand on what should be done here, or how that should affect the accessibility tree ?

@gabalafou
Copy link
Author

We went over this is in the team sync yesterday.

Reiterating here, for reference, the issue is that when you cycle through the three states (light, dark, auto) of the light/dark button (which is in the top right of the PST docs), the current state of the button is reflected visually, but nowhere is this visual state communicated in a textual way in the DOM. For assistive tech, it's important that the current state of the button is reflected in the accessibility tree.

@Carreau
Copy link

Carreau commented Jun 28, 2024

Thanks, I managed to see the accessibility tree in my dev console and will look into modifying it when the button switches.

@Carreau
Copy link

Carreau commented Jul 8, 2024

I'm reading the various aria things, and I'm wondering if the theme switch button should be an option dropdown with 3 options (auto, light, & dark).

It seem like a 3 state button is a bit of a hack (and maybe less discoverable than an option?)

I think the UI could be almost identical, but making it an option would maybe solve most of our Accessibility concerns.

Thoughts ?

@Carreau
Copy link

Carreau commented Jul 8, 2024

Also, I'm not sure we can do anything abut that, but the button tooltip on hover/focus seem to be added/removed by js (via bootstrap?), which removes and add a new aria-describedby attribute on every hover.

Should this aria-describedby (and tooltip element) always be present, but just visually hidden to be properly supported by screen readers ?

@Carreau
Copy link

Carreau commented Jul 8, 2024

be an option dropdown

And I suppose I mean a select

@Carreau
Copy link

Carreau commented Jul 8, 2024

Speaking of, this is what MDN is doing, I'm trying to see if we can set aria-description anyway on the the body element, but that does not seem to work. There is no way to directly modify the accessibility tree.
Screenshot 2024-07-08 at 15 33 03

@Carreau
Copy link

Carreau commented Jul 9, 2024

Ok, so select won't work because we can't style it with icons. So we have a to do a custom dropdown which does not fix our accessibility issue. aria-desciption does no show up in the accessibility tree, and aria-label is already set to "light/dark" translatable string.

I guess we can change the aria label to a dynamic string like : "Switch theme. Current theme : %s". though it's unclear how to translate a dynamic js string. I also realize that "auto" is unclear. MDN uses "Os default" as a description.

@gabalafou
Copy link
Author

@gabalafou
Copy link
Author

Responding to some of your points:

  • I agree that the tri-state button is an unconventional pattern. A dropdown is probably preferred (that was the consensus in the discussion I linked in my previous comment). It's more work, though, and I think we could fix the specific accessibility issue here with much less effort. But I will leave it up to your judgment, whether to re-implement the theme switcher now or later.
  • As for the Bootstrap tooltips/popovers, I would check the docs to see if they have some option that might address our use case here, otherwise I would just leave them alone as a completely other thing.
  • As for translatable strings in JavaScript, it might be worth working on solving this problem once and for all, especially if it turns out their is an elegant, low-maintenance way to do so. I suspect it will come up again. However, I don't think you need it for this issue. We use Font Awesome icons in the theme-switcher.html Jinja template. I suspect that the Font Awesome accessibility docs provide a pathway to adding translatable strings in the Jinja template that then also show up in the accessibility tree.

Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Jul 11, 2024
This will add a `<title>` attribute to the SVG generated by font
awesome, which will in turn update the Accessibility tree, which will
now be

  - button "light/dark" focusable: true focused: bool
     - image: $title-text

Should fix Quansight-Labs/czi-scientific-python-mgmt#76
@gabalafou
Copy link
Author

Some thoughts from today's call:

  • Eventually we should probably get rid of the light/dark/auto mode toggle button and push that functionality back to the system (browser, OS).
  • Perhaps we imitate the search button and open a modal dialog with a deprecation notice and three buttons.
  • The deprecation notice could link the user to info on how to set light/dark mode on their system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🏗 In progress
Development

Successfully merging a pull request may close this issue.

3 participants