Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Add tabindex-1 to fix the skiplink in Safari#225

Merged
aduggin merged 2 commits intomasterfrom
add-tabindex-to-fix-skiplink
May 25, 2016
Merged

Add tabindex-1 to fix the skiplink in Safari#225
aduggin merged 2 commits intomasterfrom
add-tabindex-to-fix-skiplink

Conversation

@gemmaleigh
Copy link
Copy Markdown
Contributor

@gemmaleigh gemmaleigh commented May 16, 2016

The GOV.UK template sets a skiplink to #content (just tab on any GOV.UK page and hit ENTER when "Skip to main content" is highlighted).

This allows users to navigate to the main content area using only the keyboard. Pressing enter when focus is on the skiplink should then set focus on the #content area.

In Safari, there's a bug where this doesn't happen unless tabindex="-1" is set on the destination element (in this case <main id="content">).
Here's the bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=37721

This pull request adds:

  • tabindex="-1" to the <main> element wherever it appears in a template

cc. @aduggin.

Chromium bug: Skip links do not work when using screenreader.
https://bugs.chromium.org/p/chromium/issues/detail?id=37721

Once the page has loaded, press tab to navigate the page.
Tab to a skip link and press enter.

Adding tabindex="-1" to the destination element fixes this.
@gemmaleigh gemmaleigh force-pushed the add-tabindex-to-fix-skiplink branch from 05ff27b to 09f2e28 Compare May 25, 2016 15:01
Pressing enter when focus is on the skiplink sets focus on the #content
area, remove this outline.
@aduggin aduggin merged commit 4cb1170 into master May 25, 2016
@robinwhittleton robinwhittleton deleted the add-tabindex-to-fix-skiplink branch May 26, 2016 12:37
robinwhittleton pushed a commit that referenced this pull request May 26, 2016
# 1.2.0

- Add MIT License (PR #236)
- Create latest release branch as an alias of the latest release (PR
#232)
- Create new app to preview govuk elements sass releases (PR #219)
- Fix the summary arrow in recent Firefox (PR #227)
- Remove button padding overriding the govuk_frontend_toolkit (PR #230)
- Don't copy the govuk_frontend_toolkit's images into an icons folder
(PR #223)
- Fix path for rails and node environments (PR #234)
  - Import the govuk_frontend_toolkit url-helpers partial
  - If image-url is not defined (if we are not in a Rails environment),
then set a path to /public/images
- Fix the skip link in Safari (PR #225)
@robinwhittleton robinwhittleton mentioned this pull request May 26, 2016
@fofr
Copy link
Copy Markdown
Contributor

fofr commented Jul 21, 2017

Can this bug still be reproduced? What versions of Safari are affected and what's their usage?
See problems here: alphagov/govuk_template#321

@fofr
Copy link
Copy Markdown
Contributor

fofr commented Jul 21, 2017

On GOV.UK which does not have tabindex set:
Testing on Safari 10.1.1 it works with VoiceOver on desktop.
Testing on iOS 10.2.1 it works in mobile Safari with VoiceOver on.

fofr added a commit that referenced this pull request Jul 21, 2017
Reverts #225

See: alphagov/govuk_template#321

Putting tabindex on the `<main>` element causes different problems:

* Some apps will display the browser's default focus styles around the
main element
* When clicking anywhere in the page focus will return back to the top
Consider a user interacting with an input field who clicks away from it
to remove the focus style. Should they then hit tab they will be taken
to the top of the page.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants