Skip to content

Commit

Permalink
Disable ink skipping for underlines in hover state
Browse files Browse the repository at this point in the history
The thick underlines we use in the new hover states are rendered
differently by different browsers. In Safari and Firefox, links can
look messy if the link text contains words with lots of descenders.

Disable ink skipping on hover, which means that links look closer to the
way they do in Safari currently.

Use both `text-decoration-skip-ink: none;` and `text-decoration-skip: none;`
– Safari supports `text-decoration-skip` whilst other browsers support
`text-decoration-skip-ink`. Fun!
  • Loading branch information
Chris Thomas authored and 36degrees committed Jun 14, 2021
1 parent 279606d commit e873ed5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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 () => {
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

0 comments on commit e873ed5

Please sign in to comment.