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

Fix invisible footer on Open Government Licence logo in forced colors mode #2273

Merged
merged 2 commits into from
Jul 9, 2021

Conversation

36degrees
Copy link
Contributor

When forced color mode was introduced in Chrome 89, the default user agent styles for SVGs were set to forced-color-adjust: none in line with the CSS Color Adjustment specification at the time. Unfortunately, this means that using currentColor for stroke and fill in SVGs no longer works as expected in forced color mode.

As per the comment in Chromium bug #1164162:

This is the result of one of the recent spec changes. The spec was updated to force colors at used value time rather than computed value time, which means elements that have "forced-color-adjust: none" set (like svg elements) will inherit their non-forced color values, resulting in a different currentcolor used for stroke and fill in this case than you would get if forcing was done at computed value time.

See spec issue resolution for more details: w3c/csswg-drafts#4915

It looks like this has since been flagged as an issue with the CSS working group and the spec has been updated to resolve it but it’s going to take a while before that change is reflected in browsers.

In the meantime, we can explicitly set forced-color-adjust: auto on the OGL logo in order for it to correctly inherit the color from the parent.

Theme Before After
Black hcm-dark-before hcm-dark-after
White hcm-light-before hcm-light-after
# 1 hcm-1-before hcm-1-after
# 2 hcm-2-before hcm-2-after

Once Chromium has been updated so that the default UA styles for SVGs use the new forced-color-adjust: preserve-parent-color keyword, and traffic to older versions has dropped off, we can then consider removing this.

Fixes #2272

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2273 July 9, 2021 08:48 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2273 July 9, 2021 08:49 Inactive
When forced color mode was introduced in Chrome 89, the default user agent styles for SVGs were set to `forced-color-adjust: none` in line with the CSS Color Adjustment specification at the time [1]. Unfortunately, this means that using currentColor for stroke and fill in SVGs no longer works as expected in forced color mode.

As per the comment in Chromium bug #1164162 [2]:

> This is the result of one of the recent spec changes. The spec was updated to force colors at used value time rather than computed value time, which means elements that have "forced-color-adjust: none" set (like svg elements) will inherit their non-forced color values, resulting in a different currentcolor used for stroke and fill in this case than you would get if forcing was done at computed value time.
>
> See spec issue resolution for more details: w3c/csswg-drafts#4915

It looks like this has since been flagged as an issue with the CSS working group [3] and the spec has been updated to resolve it [4] but it’s going to take a while before that change is reflected in browsers.

In the meantime, we can explicitly set `forced-color-adjust: auto` on the OGL logo in order for it to correctly inherit the color from the parent [5].

Once Chromium has been updated so that the default UA styles for SVGs use the new `forced-color-adjust: preserve-parent-color` keyword, and traffic to older versions has dropped off, we can then consider removing this.

[1]: https://www.w3.org/TR/2021/WD-css-color-adjust-1-20210520/#forced-color-adjust-prop
[2]: https://bugs.chromium.org/p/chromium/issues/detail?id=1164162#c4
[3]: w3c/csswg-drafts#6310
[4]: https://www.w3.org/TR/2021/WD-css-color-adjust-1-20210616/#forced-color-adjust-prop
[5]: w3c/csswg-drafts#6310 (comment)
@36degrees 36degrees force-pushed the footer-ogl-logo-forced-color-mode branch from d594e26 to b82ca21 Compare July 9, 2021 10:52
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2273 July 9, 2021 10:52 Inactive
@36degrees 36degrees merged commit 6cf0940 into main Jul 9, 2021
@36degrees 36degrees deleted the footer-ogl-logo-forced-color-mode branch July 9, 2021 12:30
@EoinShaughnessy EoinShaughnessy changed the title Fix invisible footer OGL logo in forced color mode Fix invisible footer OGL logo in forced colors mode Aug 17, 2021
@EoinShaughnessy EoinShaughnessy changed the title Fix invisible footer OGL logo in forced colors mode Fix invisible footer on Open Government Licence logo in forced colors mode Aug 31, 2021
@vanitabarrett vanitabarrett mentioned this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

footer OGL logo not visible in windows high contrast mode (flagged in an accessibility audit)
3 participants