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

Switch toggles focus style #1562

Closed
afercia opened this issue Jun 28, 2017 · 10 comments
Closed

Switch toggles focus style #1562

afercia opened this issue Jun 28, 2017 · 10 comments
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).

Comments

@afercia
Copy link
Contributor

afercia commented Jun 28, 2017

It would be great to have some design idea for the switch toggles focus style:

screen shot 2017-06-28 at 17 06 20

/cc @jasmussen @melchoyce 🙂

@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jun 28, 2017
@jasmussen
Copy link
Contributor

I actually tried adding a focus style to this a while back, and it seems like the way it's built it's hard to add such a thing :|

That doesn't mean it can't be done. It just means I couldn't get it done. But if we can't do it ever, we might want to look at an alternative.

The reason I like the switch as a form element is that it not only implies something is being toggled, but that the choice is also saved right then and there. Contrast to a checkbox, which is usually accompanied by a "Save Changes" button.

Given we can add a focus style to this switch, I like how Bear app does it:

bear

@afercia
Copy link
Contributor Author

afercia commented Jun 29, 2017

At Yoast, we use a similar UI control and we've implemented the focus style around the "knob" (built with two inner box-shadows). That's facilitated by the fact "our" toggle knob is a bit bigger, not sure a similar solution would fit the case of the Gutenberg switch toggle. Posting here for inspiration 🙂

switch toggle focus

@jasmussen
Copy link
Contributor

I dig it. The visual style is less important, so long as we can add focus rectangles. Do you happen to have some markup we can look at? Thank you!

@afercia
Copy link
Contributor Author

afercia commented Jun 29, 2017

Markup no :) The CSS in our case is something like:

box-shadow:
	inset 0 0 0 1px #fff,
	0 0 0 1px #5b9dd9,
	0 0 2px 1px rgba(30, 140, 190, .8);

but this would beed to be adjusted, also because in the Gutenberg switch the background color becomes blue when active. The basic idea is:

  • the first, inner shadow adds a white ring without increasing the knob size (needs a different color when active?)
  • the other two box-shadows mimic the standard focus style (but also in this case they won't be visible when the background is blue)

@dpersing
Copy link

dpersing commented Jul 6, 2017

Hi all!

For focus states, I'd consider using a style other than box-shadow because it doesn't display correctly for low vision users relying on Windows High Contrast themes. High Contrast generally replaces default text and border colors and strips out background colors and shadows. Additionally, it displays background images in Edge only. Using a transparent border can make elements that rely on background color visible in High Contrast, but you'd still want an additional style, such as an upgraded outline, on focus, so that users can see the difference.

My coworker Joe made a Codepen demonstrating how box-shadow is removed in High Contrast. Here are a couple of screenshots showing the difference with and without the transparent border as well.

You can try out High Contrast by opening up the Windows display settings!
2017-07-06_11-08-31
2017-07-06_11-08-57

@afercia
Copy link
Contributor Author

afercia commented Jul 9, 2017

Hm, I'm afraid the High Contrast mode issue is something that hasn't been addressed in WordPress yet. Almost all focusable elements in the admin use box-shadow for the focus style. In Windows High Contrast mode there's basically no focus indication at all 😞 macOS instead seems to apply some outline.
It is indeed something to address at a broader level and I'd propose to discuss it in the next a11y weekly meeting happening tomorrow (July 10) at 17:00 UTC on Slack #accessibility . @dpersing do feel free to join! Any feedback and help more than welcome.

@dpersing
Copy link

dpersing commented Jul 10, 2017

@afercia Sounds great! Looking forward to joining today.

@afercia
Copy link
Contributor Author

afercia commented Jul 12, 2017

Worth noting support for Windows High Contrast Mode is also mentioned in the initial accessibility recommendation issue, see point 5. in #297

@afercia
Copy link
Contributor Author

afercia commented Jul 24, 2017

I've played a bit with this. By changing the :after CSS generated pseudo element to a <span> we can easily target it when the input is focused using just CSS: input:focus + span.
At this point we can apply any style, and we can also distinguish between the checked/not checked state. Just needs some design feedback. @jasmussen

Just as an example, not pretending these should be the final styles, I've tried to use some borders. Only the last style uses a border + box-shadow:

screen shot 2017-07-24 at 16 06 18

Maybe worth experimenting a bit inverting background/border colors.

@afercia
Copy link
Contributor Author

afercia commented Jul 24, 2017

Experimenting: normal, normal focused / checked, checked focused:

screen shot 2017-07-24 at 16 24 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

No branches or pull requests

3 participants