question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add tabindex to main element landmark

See original GitHub issue

In the header of MDN Web Docs we provide context-sensitive skips links to the main content, language selector(Only on the homepage. There are two bugs here which I will log separately), and search. For non-natively focusable elements, we need to add tabindex="-1" to make them focusable.

The search link links to the search input which is natively focusable so we are all good here. When we address the link to the language selector we need to ensure it links to the select element. The main element is not natively focusable and so it needs the addition of tabindex="-1"

Why? Well,

Some browsers, such as Safari, require the link destination to either be natively focusable (such as a link, button, or form element), or have a tabindex value to function correctly. If the link is not focusable and does not have a tabindex value, the viewport will scroll down to the appropriate place, but when the user presses the tab key, the focus will jump back up to the next link after the “skip navigation” link, when it should jump to the next link after the destination.

See additional context: https://github.com/mdn/yari/issues/2755#issuecomment-770586949

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:38 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
schalkneethlingcommented, Feb 1, 2021

From what I can confirm: The issue happens the same on Firefox for Android with TalkBack. The quote in your first article mentions „Some browsers, such as Safari” - so it’s not limited to it.

For sure, but the solution proposed here will cover all browsers and platforms. Thank you for confirming.

1reaction
ghostcommented, Jan 31, 2021

tabindex=0 on main, that’s all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How-to: Use the tabindex attribute - The A11Y Project
tabindex is a global attribute that allows an HTML element to receive focus. It needs a value of zero or a negative number...
Read more >
Tab Index - Better Accessibility with Javascript | Code Demo
Add a logical tab index. ... Setting all elements to tabindex="0" means they will be focused in the order they appear in the...
Read more >
Tab Index - Penn State | Accessibility
When the TABINDEX attribute is used on any element you need to add TABINDEX attributes for all sections of the page to maintain...
Read more >
ARIA: tab role - Accessibility - MDN Web Docs - Mozilla
The ARIA tab role indicates an interactive element inside a tablist that, when activated, displays its associated tabpanel.
Read more >
Tabindex for accessibility: Good, Bad and Ugly - Maxability
Tabindex is a HTML attribute that can set an order for focusable elements which allow keyboard focus for non focusable elements and remove ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found