Skip to content

Commit

Permalink
Fix display of warning text in High Contrast Mode
Browse files Browse the repository at this point in the history
When Windows High Contrast Mode (HCM) is enabled for Edge, the warning text icon is affected by the readability backplate [1] which draws a box around the exclamation mark, obscuring parts of the circle.

Opt out of the readability backplate by setting `forced-color:adjust: none` and handle it ourselves, by overriding the colors to system colours in a media query which detects if forced colors are active.

Use `forced-color-adjust` and `forced-colors` over the MS specific `-ms-high-contrast-adjust: none;` and `-ms-high-contrast: active` to allow for future support from other browsers (e.g. Firefox, which allows users to set their own colour scheme for pages).

HCM with IE11 does not seem to be affected by the same issue – I don’t think it implements a readability backplate.

[1]: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/6208eaffa0362ca107644c99b902c0b06bd5a0c8/Accessibility/HighContrast/explainer.md#ensuring-readability
  • Loading branch information
36degrees committed Apr 13, 2021
1 parent 3480696 commit 5fd24a7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/govuk/components/warning-text/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
// Prevent the exclamation mark from being included when the warning text
// is copied, for example.
user-select: none;

// Improve rendering in Windows High Contrast Mode (Edge), where a
// readability backplate behind the exclamation mark obscures the circle
forced-color-adjust: none;

@media screen and (forced-colors: active) {
border-color: windowText;
color: windowText;
background: transparent;
}
}

.govuk-warning-text__text {
Expand Down

0 comments on commit 5fd24a7

Please sign in to comment.