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

Port visually hidden whitespace announcement improvement #4027

Merged
merged 2 commits into from
Jul 31, 2023

Conversation

owenatgov
Copy link
Contributor

@owenatgov owenatgov commented Jul 31, 2023

Ports #3836 fromsupport/4.x to main. More details of the change can be found on the original pull request.

Part of #3775

@owenatgov owenatgov requested a review from a team July 31, 2023 10:07
@owenatgov owenatgov self-assigned this Jul 31, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4027 July 31, 2023 10:07 Inactive
Absolute positioning has the unintended consequence of removing any whitespace before or after visually hidden text from the accessibility tree. This can lead to unintelligible screen reader announcements, such as the GOV.UK search results heading being announced as "Searchall content", instead of "Search all content".

Insert a space character before and after visually hidden text using pseudo elements to ensure correct screen reader announcements of visually hidden text with surrounding whitespace. This tests well in all screen readers, regardless of whether the whitespace is before the visually hidden text ("Search all content"), after the visually hidden text ("Countries starting with A") or where the heading text is only made up visually hidden text ("Navigation menu"). The only slight issue I found is that Mac VoiceOver in Safari explicitly announces the inserted spare characters when navigating by headings - but this is unlikely to block any users and the user numbers for Mac VoiceOver are small compared to other assistive technologies.

I also looked into using `opacity: 0`, without `position: absolute` - this tested well in all screen readers and browsers, with the text visually hidden but accessible to assistive technologies. However, as it doesn't remove the element from the page flow, long visually hidden text would end up wrapping and pushing other elements down the page. Another alternative, also explored on the original ticket would be to use a non-breaking space  . This also tested well, but would require always to be inserted in the markup along the visually hidden text, making it more of a manual fix which might also get accidentlaly removed by the next person working in the file. Another alternative would have been to use aria-label with "Search all content" but this doesn't get announced at all by JAWS and Mac VoiceOver (even though it fixes the iOS VoiceOver issue and seems to be allowable content on headings).
@owenatgov owenatgov force-pushed the port-visually-hidden-whitespace-improvement branch from 2b933b9 to 2d24e73 Compare July 31, 2023 12:56
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4027 July 31, 2023 12:56 Inactive
@owenatgov owenatgov merged commit d5456e0 into main Jul 31, 2023
@owenatgov owenatgov deleted the port-visually-hidden-whitespace-improvement branch July 31, 2023 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants