Problem/Motivation
#3584347: Deprecate and replace system_admin_compact_mode() moved the logic which controls the visibility of descriptions from the backend to the frontend. The Hide descriptions / Show descriptions link was inherited from the previous design. The use of a link isn't ideal from an accessibility POV:
As per Curtis Wilcox on slack:
Importantly, the current control changes its name to convey the state, "Hide descriptions" / "Show descriptions"; a control should not use both attributes and name changes to convey state. Attribute changes are more reliably conveyed to screen reader users.
Steps to reproduce
Proposed resolution
Curtis Wilcox further suggests:
Because there's no mixed state (there's no way a user could show only some of the descriptions), [...] a toggle switch could be implemented using
<input type="checkbox" switch>; only Safari has shipped support for the HTML switch attribute but there's a robust polyfill for it.I mainly suggest using that not because I think Safari's move to ship switch was good but because I know the polyfill has done a good job on all the design considerations and I know many others have not. For instance, the "thumb" part of the switch must be at the start position when it's off and the end position when it's on; in left-to-right languages like English, that's left for off, right for on.
The HTML might be something like this (I mildly prefer the input being visually before the label but either is fine):
<div class="compact"> <input id="compact-switch" type="checkbox" switch> <label for="compact-switch">Hide Descriptions</label> </div>
Comments
Comment #2
znerol commentedComment #3
znerol commentedComment #4
kentr commentedTo me, it would be good to create a generic Switch element that can be used in other cases. The admin compact mode toggle could then use that.
Default admin already has some functionality related to this, used for general checkboxes. Perhaps some of it could be moved to central libraries (or removed, if the polyfill takes care of it).
Comment #5
kentr commentedI'm noting a discussion regarding the limitations of Safari's
switchelement: https://github.com/whatwg/html/issues/4180#issuecomment-1991750824Ability to be styled might be a sticking point for using it along with the polyfill. I played around with the polyfill demo in Safari and haven't figured out how to style it yet.
I recall reading somewhere that Apple's stance on this is that some UI elements shouldn't change style between websites and native apps (I might be misremembering).
But I also know that difficulty with styling UI components has caused accessibility problems for us, such as with the color contrast ratio of placeholders in date / time fields (
<input type="date">, for example).Adding Accessibility and Usability tags.
Comment #6
alexpott+1,000,000
This would be fantastic. FWIW the experimental default_admin theme already converts single checkboxes to a switch so maybe we can look at bringing this into core and making it intentional instead of magical.
Comment #7
kentr commentedIt seems that this will only be relevant when the behavior changes to JavaScript in #3584347: Deprecate and replace system_admin_compact_mode(), so postponing on that.
I think it will also be related to SC 4.1.2 Name, Role, Value (Level A) because the
linkrole of the current markup will be incorrect when this control is a JavaScript toggle of any kind.In the larger picture, I think that changing to switches will also apply in cases like the "Show / Hide all columns" button for responsive tables. I think the consistency will be better for UX.
I gave credit to @cwilcox808 for his help in Slack.
Comment #8
kentr commentedComment #9
kentr commentedInteresting that Adrian Roselli recommended against using the
switchrole and recommends using abuttoninstead.Comment #10
kentr commentedFollowup to #9:
@cwilcox808 said in Slack that he thinks the current browser situation with regard to announcing the changes for
role="switch"is fine.