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

Disable ink skipping for underlines in hover state #2251

Merged
merged 2 commits into from
Jun 16, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [#2229: Change approach to fallback PNG in the header to fix blank data URI from triggering Content Security Policy errors](https://github.com/alphagov/govuk-frontend/pull/2229)
- [#2229: Fix alignment of fallback PNG in the header](https://github.com/alphagov/govuk-frontend/pull/2229)
- [#2237: Fix GOV.UK logo disappearing on light background in Windows High Contrast Mode](https://github.com/alphagov/govuk-frontend/pull/2237)
- [#2251: Disable ink skipping for underlines in hover state](https://github.com/alphagov/govuk-frontend/pull/2251)

## 3.12.0 (Feature release)

Expand Down
4 changes: 4 additions & 0 deletions src/govuk/helpers/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
@mixin govuk-link-hover-decoration {
@if ($govuk-new-link-styles and $govuk-link-hover-underline-thickness) {
text-decoration-thickness: $govuk-link-hover-underline-thickness;
// Disable ink skipping on underlines on hover. Browsers haven't
// standardised on this part of the spec yet, so set both properties
text-decoration-skip-ink: none; // Chromium, Firefox
text-decoration-skip: none; // Safari
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/govuk/helpers/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('@mixin govuk-link-hover-decoration', () => {
})

describe('when $govuk-new-link-styles are enabled', () => {
it('sets text-decoration-thickness on hover', async () => {
it('sets a hover state', async () => {
Copy link
Member

@hannalaakso hannalaakso Jun 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave this test as it is, and add a new test for ink skipping that tests for the presence of the styles?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test has to change because it no longer passes:

  ● @mixin govuk-link-hover-decoration › when $govuk-new-link-styles are enabled › sets text-decoration-thickness on hover

    expect(received).toContain(expected) // indexOf

    Expected substring: ".foo:hover { text-decoration-thickness: 10px; }"
    Received string:    ".foo:hover { text-decoration-thickness: 10px; text-decoration-skip-ink: none; text-decoration-skip: none; }

We could add tests for each of the properties, but I don't think we want to test the CSS itself, just the logic that surrounds it. In this case, we want to know how the mixin behaves differently depending on the various link settings:

  • by default there's no hover state
  • when $govuk-new-link-styles are enabled, there is a hover state (but we don't care exactly what that hover state looks like – that's what manual testing is for)
  • except when $govuk-link-hover-underline-thickness is falsey, in which case the hover state is removed

I think the revised tests cover this. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @36degrees that covers it 👍

const sass = `
$govuk-new-link-styles: true;
$govuk-link-hover-underline-thickness: 10px;
Expand All @@ -133,7 +133,7 @@ describe('@mixin govuk-link-hover-decoration', () => {

const results = await renderSass({ data: sass, ...sassConfig })

expect(results.css.toString()).toContain('.foo:hover { text-decoration-thickness: 10px; }')
expect(results.css.toString()).toContain('.foo:hover')
})

describe('when $govuk-link-hover-underline-thickness is falsey', () => {
Expand Down