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.

Focus trap does not respect tabindex

See original GitHub issue

Bug, feature request, or proposal:

Bug.

What is the expected behavior?

Focus trap will focus elements with respect to tabindex attribute.

What is the current behavior?

When a dialog body (or any other focus trap) contains a HTML like this:

<input type="text" tabindex=2 ...>
<button tabindex=1 ...>

the input is focused, but the button should be obviously.

In addition using higher tabindex then 0 causes the focus trap to stop working at all. The anchors have tabindex 0 and are focused after all other elements on the page with tabindex not set. User is therfore able to focus elements under dialog overlay.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular 4.2.4 @angular/material 2.0.0-beta.7

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sinediedcommented, Apr 11, 2018

Any news on this? It’s quite problematic that focus trap stops working once a tabIndex is set inside a dialog 😕

2reactions
crysislinuxcommented, Jan 30, 2018

For someone just want set the initial focused element but don’t require detail orders. Use cdkFocusInitial directive on the element you want it to focus on first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Focus trap does not respect tabindex · Issue #5435 - GitHub
Focus trap will focus elements with respect to tabindex attribute. What is the current behavior? When a dialog body (or any other focus ......
Read more >
Using tabindex - web.dev
In instances like this you can implement a temporary keyboard trap to ensure that you trap focus only while the modal is displayed...
Read more >
Browser is not respecting tabindex setting - Stack Overflow
I have added tabindex="1" to the link which you can see here, but the browser doesn't seem to respect it at all (tested...
Read more >
Focus Trapping for Accessibility (A11Y) | by Rahul Kumar
In this article, I will cover one of the important aspects of making a web-page accessible — trapping/looping (will call it looping from ......
Read more >
Avoid positive tabindex values
... tabindex="0" if an interactive element doesn't naturally receive focus ... is usable with single pointer inputs · Ensure there are no keyboard...
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