alphagov / govuk-design-system

One place for service teams to find styles, components and patterns for designing government services.
https://www.gov.uk/design-system
MIT License
512 stars 232 forks source link

SPIKE: How should we communicate Exit this Page interaction to screen readers? #2386

Closed owenatgov closed 2 years ago

owenatgov commented 2 years ago

What

Investigate how best to communicate to screen reader users that they are interacting with the Exit this Page button. Specific questions we want to answer:

Epic: https://github.com/alphagov/govuk-design-system/issues/1755

Prototype: https://github.com/alphagov/govuk-frontend/pull/2545

Time limit: 1 week

Why

Following research on Exit this Page with users with access needs, we hypothesise that we need to better communicate the use of the button to screen reader users. However we're not confident about how much we should communicate to the user, how to communicate and if our current implementation hampers this.

Who needs to work on this

Developers, Accessibility specialists

Done when

owenatgov commented 2 years ago

As I'm investigating this, despite an effort to rework the 3xEsc key functionality, I'm finding that it doesn't work at all on firefox. There seems to be a push-pull of bugs between 3xEsc not working at all in firefox and it being very choppy or not working on pages across all browsers where the user has yet to interact with the page in a meaningful way. Will continue to investigate.

owenatgov commented 2 years ago

Investigation findings

I've put together a testing sheet to record my findings.

Summary of results

Technical issues

In the above comment I mentioned that the 3xEsc feature wasn't working reliably. I believe it's in a reliable state now, however the reason I believe it was being unreliable and in some cases actively broken was because browsers were flagging the js as malicious code. I can't find any documentation or evidence for this so it's purely my speculation, although it wouldn't be surprising if browser vendors made a conscious choice not to document this for security reasons. A lot of what we're doing for Exit this Page risks making browsers "suspicious" even if we don't have any ill intent.

Parts of the code that browsers appear to take note of when determining if code is malicious or not:

That latter one has meant that I've not been able to get the 3xEsc functionality working without abandoning the update on navigation.

Thoughts and recommendations

I think the button press announcement needs content designing but don't think it's necessarily a derogatory feature. We could also consider expanding the key press timeout from 2 seconds.

The lack of ability to reliably announce button activation is problematic. We may have to weigh up the value of the 3xEsc feature vs activation announcement. I don't think it's critical that we announce button activation as it's a pattern in screen readers to not explicitly announce navigation.

The technical issue on adding listeners to links may have a negative impact on future feature investigations, most notably https://github.com/alphagov/govuk-design-system/issues/2389 which would be tied to button activation.

owenatgov commented 2 years ago

Update

I've managed to get the 3xEsc feature to work reliably by switching the event listened for to trigger the behaviour via keyup instead of keydown. I'm not certain exactly if there's different weighting between the 2 events in terms of what counts as user interaction or of keydown is already being used in browsers for something else.

I've therefore updated the testing sheet linked above with results on activating the button.

New thoughts and recommendations

I think both an announcement that the esc key has been pressed and that the button has been activated have value. I think the latter far outweighs the former as we've identified that the time it takes to announce the message cuts into the key timer.

jbuller commented 2 years ago

It's is an interesting challenge to balance informing the screenreader user what's going on vs their abuser not hearing it as they approach (and a similar one for voice input users too).

owenatgov commented 2 years ago

Some extra thoughts from a chat with @davidc-gds:

For now I'm going to close this and we can assess the results of all the button behaviour spikes current in flow as one to see how they might impact each other and how to solve some of these lingering problems.