Repository navigation
Description
Describe the Issue
I've been wanting to fix the toggle buttons on the Settings page for quite a while now. PR #48567 has already been started to implement a new ToggleButton component. I wanted to create this issue to make sure that any new components address all of the current accessibility issues. The current toggles have several issues:
- Their labels are not associated with their input
- They are not always keyboard accessible
- Some of them do not use the correct inputs for their functionality
There are two types of toggles on the Settings page:
- Toggles that invoke change immediately when the toggle value is changed (e.g. Night Mode, Campfire Mode).
- Toggles that only take effect when the corresponding Save button is clicked (e.g. the Privacy Settings).
These two toggles need to be created a little differently.
One option for the immediately invoked toggles is to use a group of two button elements, using the aria-pressed attribute to signal to screen readers which one is currently set. I have put together a codepen to demonstrate how this should be marked up and function.
Accessible Toggle Group Using Buttons
Some of these types of toggles are of the On/Off variety and thus we could use an aria switch input for them if we wanted to introduce a third type of toggle. But I don't think this is a necessity, especially because one of these toggles is not On/Off. I think it would be better to be consistent across all of these toggles. So either use buttons for them all or make them all On/Off toggles and use a switch.
The "delayed" toggles that can only be triggered with the Save button should be composed of a group of radio buttons. No special aria attributes need to be used here.
Accessible Toggle Group Using Radio Button Inputs
A few questions:
- Do we want to create separate components for each type of toggle?
- The toggles should be wrapped in
fieldset/legends. Do we want to include that in these toggles?
Affected Page
Steps to Reproduce
N/A
Expected behavior
See above write-up.
Screenshots
No response
System
N/A
Additional context
No response
Activity
Sboonny commentedon Feb 3, 2023
I am in favor of two components that looks different, because they have different interaction with the API.
I am in favor of adding the
legendandfieldset, although styling can be hard, we can add propertyall: unsetto them, which put them in the blank state in the canvas, and we can style them however we want.bbsmooth commentedon Feb 9, 2023
I think that would be a good idea since their keyboard interaction is slightly different and this would let visual keyboard users know that.
Sboonny commentedon Mar 8, 2023
- we need to add focus indication for both, which should be sorted in this PR #49579that PR isn't solving it because of bootstrap default setting getting in the way, I will create a PR to sort bootstrap styles.rec-tab.15.webm
We can open new issue for the components to keep the changes small.
If you would like to fix this issue, please make sure you read our guidelines for contributing, we prioritize contributors following the instructions in our guides. Join us in our chat room or the forum if you need help contributing, our prolific contributors will guide you through this.
Sboonny commentedon Mar 8, 2023
To solve this issue, wrap the input in fieldset and legend for accessibility.