question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checkbox focus outline not visible in high contrast mode

See original GitHub issue

No checkbox focus outline in high contrast mode

Environment

OS

Windows 10 etc.

Browsers

IE11, Edge Chromium, Firefox

Settings

High Contrast Theme #1 enabled

Detailed description

What version of the Carbon Design System are you using?

10.14

What did you expect to happen?

To see a focus outline on the checkbox, like when high contrast mode is disabled.

What happened instead?

No focus outline.

What WCAG 2.1 checkpoint does the issue violate?

https://www.w3.org/WAI/WCAG21/Understanding/focus-visible.html

Steps to reproduce the issue

The problem is not specific to react but you can see it at https://react.carbondesignsystem.com/?path=/story/checkbox--checked.

Additional information

Here’s what it looks like, regardless of whether or not it’s focused:

Screen Shot 2020-07-15 at 15 32 26

The problem is that the focus outline is rendered via box-shadow rather than outline:

  // Unchecked
  .#{$prefix}--checkbox:focus + .#{$prefix}--checkbox-label::before,
  .#{$prefix}--checkbox-label__focus::before,
  // Checked
  .#{$prefix}--checkbox:checked:focus + .#{$prefix}--checkbox-label::before,
  .#{$prefix}--checkbox-label[data-contained-checkbox-state='true'].#{$prefix}--checkbox-label__focus::before,
  // Indeterminate
  .#{$prefix}--checkbox:indeterminate:focus + .#{$prefix}--checkbox-label::before,
  .#{$prefix}--checkbox-label[data-contained-checkbox-state='mixed'].#{$prefix}--checkbox-label__focus::before {
    // Must use box-shadow for appearance of multiple borders with rounded corners.
    box-shadow: 0 0 0 2px $inverse-01, 0 0 0 4px $focus;
  }

The obvious fix is to use outline instead of box-shadow but assuming there’s some reason you aren’t doing that already, a possible alternative fix is:

@media screen and (-ms-high-contrast: active) {
	// Unchecked
	.#{$prefix}--checkbox:focus + .#{$prefix}--checkbox-label::before,
	.#{$prefix}--checkbox-label__focus::before,
	// Checked
	.#{$prefix}--checkbox:checked:focus + .#{$prefix}--checkbox-label::before,
	.#{$prefix}--checkbox-label[data-contained-checkbox-state='true'].#{$prefix}--checkbox-label__focus::before,
	// Indeterminate
	.#{$prefix}--checkbox:indeterminate:focus + .#{$prefix}--checkbox-label::before,
	.#{$prefix}--checkbox-label[data-contained-checkbox-state='mixed'].#{$prefix}--checkbox-label__focus::before {
		outline: 1px solid highlightText;
		outline-offset: 2px;
	}
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
tw15egancommented, Jan 19, 2021

Power is out at my house right now, but once it’s back on I’ll boot up my Windows machine and investigate what’s going on with these…

2reactions
jendownscommented, Jul 16, 2020

@carbon-design-system/ibma Can the focus state for the checkboxes be revisited… I have noticed positioning issues (see #6480), and then just saw this more serious issue about the focus state not being visible in high contrast mode.

The use of box-shadow for the checkbox’s focus state was originally to help show multiple borders with “rounded corners”. But can this library move away from that and return to using outlines (or a single border) – for accessibility, consistency, and stability?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maintaining Focus Outlines for Windows High Contrast Mode
This is a quick and easy way to remove the outline for most viewing modes, while preserving it for Windows High Contrast Mode...
Read more >
Bootstrap Switch not visible in High Contrast Mode
Per a blog post on windows.com, when the user is using a high contrast theme, the user agent colors overrides the colors for...
Read more >
Quick Tips for High Contrast Mode | Sarah Higley
1. Custom focus styles + a transparent outline ... WHCM will override the transparent outline color, making it visible only when high contrast...
Read more >
Checkbox Example (Two State) - W3C on GitHub
When an element loses focus, its border changes from 2 pixels to 0 and padding is increased by 2 pixels. To ensure the...
Read more >
Slide 23: Checkbox Example: Keyboard Focus and hover styling
Recommend focus styling has a border and hover does not. focus styling should ... styling to change when users select operating system high...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found