Skip to content

Commit

Permalink
Merge pull request #3777 from alphagov/kg-radio-checkbox-outlines-hig…
Browse files Browse the repository at this point in the history
…h-contrast

Fix hover style on small checkboxes and radio buttons in High Contrast Mode
  • Loading branch information
querkmachine committed Jul 4, 2023
2 parents aad6f92 + 2e0ac10 commit e925f2a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ This change was introduced in [pull request #3773: Omit the value attribute from

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

- [#3777: Fix hover style on small checkboxes and radio buttons in High Contrast Mode](https://github.com/alphagov/govuk-frontend/pull/3777)
- [#3791: Refactor mobile menu button label/text handling](https://github.com/alphagov/govuk-frontend/pull/3791)
- [#3862: Fix focus style being overlapped by summary action links](https://github.com/alphagov/govuk-frontend/pull/3862)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@
// feedback to the user as to which checkbox they will select when their
// cursor is outside of the visible area.
.govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {
// Forced colours modes tend to ignore box-shadow.
// Apply an outline for those modes to use instead.
outline: $govuk-focus-width dashed transparent;
outline-offset: 1px;
box-shadow: 0 0 0 $govuk-hover-width $govuk-hover-colour;
}

Expand All @@ -282,6 +286,10 @@
// We use two box shadows, one that restores the original focus state [1]
// and another that then applies the hover state [2].
.govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
// Set different HCM colour when we have both hover/focus applied at once
@media screen and (forced-colors: active), (-ms-high-contrast: active) {
outline-color: Highlight;
}
box-shadow:
0 0 0 $govuk-focus-width $govuk-focus-colour, // 1
0 0 0 $govuk-hover-width $govuk-hover-colour; // 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@
// feedback to the user as to which radio they will select when their
// cursor is outside of the visible area.
.govuk-radios__item:hover .govuk-radios__input:not(:disabled) + .govuk-radios__label::before {
// Forced colours modes tend to ignore box-shadow.
// Apply an outline for those modes to use instead.
outline: $govuk-radios-focus-width dashed transparent;
outline-offset: 1px;
box-shadow: 0 0 0 $govuk-hover-width $govuk-hover-colour;
}

Expand All @@ -302,6 +306,10 @@
// We use two box shadows, one that restores the original focus state [1]
// and another that then applies the hover state [2].
.govuk-radios__item:hover .govuk-radios__input:focus + .govuk-radios__label::before {
// Set different HCM colour when we have both hover/focus applied at once
@media screen and (forced-colors: active), (-ms-high-contrast: active) {
outline-color: Highlight;
}
box-shadow:
0 0 0 $govuk-radios-focus-width $govuk-focus-colour, // 1
0 0 0 $govuk-hover-width $govuk-hover-colour; // 2
Expand Down

0 comments on commit e925f2a

Please sign in to comment.