Skip to content

Commit

Permalink
Announce whitespace in screen reader announcements of visually hidden…
Browse files Browse the repository at this point in the history
… text (#960)

This fixes a bug in the nhsuk-u-visually-hidden helper class where any whitespace surrounding visually hidden text isn't announced by screen readers.

This fix was added to `govuk-frontend` in [pull request #3868](alphagov/govuk-frontend#3836) and has been re-applied here.

Thanks to @hannalaakso for the work upstream.

---------

Co-authored-by: hannalaakso <[email protected]>
Co-authored-by: anandamaryon1 <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2024
1 parent e8928eb commit bc50201
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/components/tables/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@

@include mq($from: desktop) {
@include visually-shown(table-header-group); /* [2] */

&:before,
&:after {
content: "";
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions packages/core/tools/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
//

@mixin visually-hidden() {
// Absolute positioning has the unintended consequence of removing any
// whitespace surrounding visually hidden text from the accessibility tree.
// Insert a space character before and after visually hidden text to separate
// it from any visible text surrounding it.
&::before {
content: "\00a0";
}

&::after {
content: "\00a0";
}

border: 0;
clip: rect(0 0 0 0);
-webkit-clip-path: inset(50%);
Expand Down

0 comments on commit bc50201

Please sign in to comment.