alphagov / government-frontend

Serves government pages on GOV.UK
https://docs.publishing.service.gov.uk/apps/government-frontend.html
MIT License
50 stars 17 forks source link

Fix the '+(xx) others' link losing focus after activation #3192

Closed matthillco closed 1 month ago

matthillco commented 2 months ago

What/Why

From Trello: When using the ‘+ 12 others’ link with JAWS, the focus is lost. Using the tab key gets you to the first inserted link. But when navigating ‘in context’, using arrow keys to read through the page, the focus for JAWS users gets moved back to the start of the page which causes them to lose their place.

More info

This was reported as an issue in JAWS. After testing, I also observed this as a problem in other screen-readers. However, this issue was potentially a problem for all users as it did not focus a relevant element after activation. It would be confusing for non-screen-reader users who use the keyboard to navigate.

The behaviour has now changed:

Styling modified:

I've tested this extensively in Assistiv Labs using JAWS, NVDA and Talkback and the behaviour now seems consistent:

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

matthillco commented 2 months ago

@AshGDS, thanks for the comments

  • The button disappears when the content is expanded - is this correct? Could this confuse users into not knowing if the button has been expanded, as it no longer exists after interacting with it?

I agree, it's a strange pattern. However, the requirement for this work is just to fix a problem with lost focus once the button is removed. As there is a task on the Trello card to review this pattern for a refactor, I think it's best not to confuse the issue as part of this work.

  • Should the button have an aria-controls on it as well, like our accordion component does?

I'm not sure. My accessibility knowledge on that is not extensive, but reading up on aria-controls suggests that usage is optional. There's certainly no harm adding it though, thanks.

matthillco commented 2 months ago

@AshGDS I've added aria-controls as you suggested, thanks.