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

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

Merged
merged 1 commit into from
May 23, 2024

Conversation

matthillco
Copy link
Contributor

@matthillco matthillco commented May 17, 2024

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:

  • Anchor element is replaced with a button for improved accessibility
  • After activation, focus the first link in the now-visible dropdown

Styling modified:

  • Button inherits parent styles to appear like a link
  • Text size increased to 16px to match surrounding elements

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

  • Use tab or up/down arrows to move through elements in screen reader view
  • When the +XX others text is focused, user activates it with enter or space
  • Other languages are displayed and the +XX others text is removed
  • The first language in the revealed list now has focus

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

Follow these steps if you are doing a Rails upgrade.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3192 May 17, 2024 14:27 Inactive
@matthillco matthillco marked this pull request as ready for review May 17, 2024 14:35
@matthillco matthillco requested review from andysellick and AshGDS May 20, 2024 14:51
Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I have a couple questions

  • 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?
  • Should the button have an aria-controls on it as well, like our accordion component does?

@matthillco
Copy link
Contributor Author

matthillco commented May 21, 2024

@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 matthillco force-pushed the link-losing-focus-with-jaws branch from d8e6c6f to 809b7bf Compare May 21, 2024 09:46
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3192 May 21, 2024 09:46 Inactive
@matthillco
Copy link
Contributor Author

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

Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - a small change needed but looking good

Reported as an issue in JAWS, and also further observed as problematic
in other screen-readers, this issue was actually a problem for all
users as it did not focus a relevant element after activation.

I've now changed the behaviour:

* Anchor element is replaced with a button for improved accessibility
* Button inherits parent styles to appear like a link
* After activation, focus the first link in the now-visible links panel
@matthillco matthillco force-pushed the link-losing-focus-with-jaws branch from 809b7bf to 33ee2ec Compare May 21, 2024 10:31
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3192 May 21, 2024 10:31 Inactive
@matthillco matthillco requested a review from AshGDS May 21, 2024 10:49
@matthillco matthillco merged commit 94ac233 into main May 23, 2024
11 checks passed
@matthillco matthillco deleted the link-losing-focus-with-jaws branch May 23, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants