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

Add docs for adding tabindex="-1" to fix the skiplink #250

Merged
merged 1 commit into from
Sep 21, 2016

Conversation

gemmaleigh
Copy link
Contributor

@gemmaleigh gemmaleigh commented Sep 15, 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.

This pull request adds documentation for adding tabindex="-1"
to the <main> element to fix this issue.

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">
Copy link
Contributor

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..

Copy link
Contributor Author

@gemmaleigh gemmaleigh Sep 21, 2016

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:blockfor main to the govuk_template css.

@NickColley
Copy link
Contributor

Thanks @gemmaleigh 👍

@NickColley NickColley merged commit d244176 into master Sep 21, 2016
@NickColley NickColley deleted the update-docs-for-skiplink branch September 21, 2016 13:47
@selfthinker selfthinker mentioned this pull request Oct 6, 2016
Guntrisoft added a commit to guidance-guarantee-programme/pension_guidance that referenced this pull request Dec 2, 2016
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
Guntrisoft added a commit to guidance-guarantee-programme/pension_guidance that referenced this pull request Dec 2, 2016
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
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.

2 participants