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 virtual cursor not moving when skip to content links used #821

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

GCHQ-Developer-847
Copy link
Contributor

@GCHQ-Developer-847 GCHQ-Developer-847 commented Feb 15, 2024

Summary of the changes

  • Fixed virtual cursor issue for "Skip to main content" link by using tabindex="-1", but I had to add a new target element rather than add it straight to the <main> because the virtual cursor wasn't quite behaving correctly.
  • Fixed virtual cursor issue for "Skip to page" link by also using tabindex="-1", and also had to change the target element because, with the original target, it was causing all the text on the page to be read out in one go after the user presses Enter on it.

See my comment on the ticket if you would like to see my research and reasoning behind choosing these solutions. In short, (for the "Skip to main content" link) using an <a> was the most effective - with no screen reader behaviour issues, and it is also a common method for skip links. It is how W3C and Deque have done it on their websites.


How to test: You can test this by doing the following with VoiceOver enabled:

  1. Tab to the links ("Skip to main content" is just before the home link on the top navigation, "Skip to page content" is just before the left hand navigation items).
  2. Press Enter.
  3. Use a keyboard shortcut which moves the virtual cursor. See the VoiceOver shortcuts for these - "VO" stated here is Caps Lock by default. I have tended to use VO + Right Arrow or VO + A to test this.

Related issue

#616

Checklist

Copy link

… virtual cursor working

For "Skip to main content" link, add <a> with tabindex of -1 as target, and for "Skip to page
content" link, replace page header heading with slot and set that as the target with tabindex of -1.
Having a tabindex of -1 helps with focus - particularly getting the virtual cursor to move. Add
eslint disable comment for <a>.

.#616
@GCHQ-Developer-847 GCHQ-Developer-847 force-pushed the fix/616-skip-to-content-virtual-cursor branch from f5eb3e5 to e7f4698 Compare February 15, 2024 16:32
@GCHQ-Developer-847 GCHQ-Developer-847 changed the title fix(root): change targets for skip links and add tabindex="-1" to get… Fix virtual cursor not moving when skip to content links used Feb 15, 2024
@GCHQ-Developer-847 GCHQ-Developer-847 marked this pull request as ready for review February 15, 2024 17:00
@GCHQ-Developer-530 GCHQ-Developer-530 merged commit a5c4777 into develop Feb 16, 2024
9 of 11 checks passed
@GCHQ-Developer-530 GCHQ-Developer-530 deleted the fix/616-skip-to-content-virtual-cursor branch February 16, 2024 10:20
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.

3 participants