-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add docs for adding tabindex="-1" to fix the skiplink #250
Conversation
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 documentation to explain that `tabindex="-1"` is required on the `<main>` element to fix this issue.
@@ -8,6 +8,13 @@ Refer to the table of [template blocks](./docs/template-blocks.md) and their def | |||
|
|||
The [govuk_template sets a skip link](https://github.com/alphagov/govuk_template/blob/master/source/views/layouts/govuk_template.html.erb#L64-L68) to `#content`, but doesn't provide an element with `id="content"`. You'll need to add `id="content"` to your main content area, to ensure the skip link will work. | |||
|
|||
<main id="content" role="main" tabindex="-1"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the tag to be main
if we've got role="main" applied? Just thinking main
has to be shimmed in older browsers..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We provide the HTML5Shiv bundled with the govuk_template JS and have added display:block
for main to the govuk_template css.
Thanks @gemmaleigh 👍 |
Makes the following changes: Remove generated gov.uk from relative print links alphagov/govuk_template#234 Fix extended footer on certain pages alphagov/govuk_template#177 Degrade gracefully when external JS can’t be loaded alphagov/govuk_template#248 Add docs for adding tabindex="-1" to fix the skiplink alphagov/govuk_template#250 Logo fixes alphagov/govuk_template#237 Remove external links styles alphagov/govuk_template#231 Don’t include both html5shiv and html5shiv-printshiv alphagov/govuk_template#254 Update govuk_frontend_toolkit to 5.0.0 alphagov/govuk_template#256 Fixed scala compilation failure for play template alphagov/govuk_template#261
Makes the following changes: Remove generated gov.uk from relative print links alphagov/govuk_template#234 Fix extended footer on certain pages alphagov/govuk_template#177 Degrade gracefully when external JS can’t be loaded alphagov/govuk_template#248 Add docs for adding tabindex="-1" to fix the skiplink alphagov/govuk_template#250 Logo fixes alphagov/govuk_template#237 Remove external links styles alphagov/govuk_template#231 Don’t include both html5shiv and html5shiv-printshiv alphagov/govuk_template#254 Update govuk_frontend_toolkit to 5.0.0 alphagov/govuk_template#256 Fixed scala compilation failure for play template alphagov/govuk_template#261
The GOV.UK template sets a skiplink to
#content
(just tab on anyGOV.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.
This pull request adds documentation for adding
tabindex="-1"
to the
<main>
element to fix this issue.