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

Improve focus state for radio and checkbox controls in forced colors mode (for example, Windows High Contrast Mode) #2264

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### Fixes

We’ve made fixes to GOV.UK Frontend in the following pull requests:

- [#2264: Improve focus state for radio and checkbox controls in forced color mode (for example Windows High Contrast Mode)](https://github.com/alphagov/govuk-frontend/pull/2264) – thanks to [@adamliptrot-oc](https://github.com/adamliptrot-oc) for reporting this issue.

## 3.13.0 (Feature release)

### New features
Expand Down
14 changes: 14 additions & 0 deletions src/govuk/components/checkboxes/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@
// Focused state
.govuk-checkboxes__input:focus + .govuk-checkboxes__label:before {
border-width: 4px;

// When colours are overridden, the yellow box-shadow becomes invisible
// which means the focus state is less obvious. By adding a transparent
// outline, which becomes solid (text-coloured) in that context, we ensure
// the focus remains clearly visible.
outline: $govuk-focus-width solid transparent;
outline-offset: 1px;

// When in an explicit forced-color mode, we can use the Highlight system
// color for the outline to better match focus states of native controls
@media screen and (forced-colors: active) {
outline-color: Highlight;
}

box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;
}

Expand Down
14 changes: 14 additions & 0 deletions src/govuk/components/radios/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@
// Focused state
.govuk-radios__input:focus + .govuk-radios__label:before {
border-width: 4px;

// When colours are overridden, the yellow box-shadow becomes invisible
// which means the focus state is less obvious. By adding a transparent
// outline, which becomes solid (text-coloured) in that context, we ensure
// the focus remains clearly visible.
outline: $govuk-focus-width solid transparent;
outline-offset: 1px;

// When in an explicit forced-color mode, we can use the Highlight system
// color for the outline to better match focus states of native controls
@media screen and (forced-colors: active) {
outline-color: Highlight;
}

box-shadow: 0 0 0 $govuk-radios-focus-width $govuk-focus-colour;
}

Expand Down