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.

On open SideBar focus on input field

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When the sidenav is opened and the user move the cursor on one of inputs the first input is always focused automatically.

What is the current behavior?

Focus should be only if user click on one of input field.

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

"@angular/animations": "5.2.3", "@angular/cdk": "5.2.0", "@angular/common": "5.2.3", "@angular/compiler": "5.2.3", "@angular/core": "5.2.3", "@angular/forms": "5.2.3", "@angular/http": "5.2.3", "@angular/material": "5.2.0", "@angular/platform-browser": "5.2.3", "@angular/platform-browser-dynamic": "5.2.3", "@angular/router": "5.2.3",

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
DeveloperFromUkrainecommented, Apr 25, 2018

Thank you for you answer, now it’s clear for me. Have a good day !

1reaction
mmalerbacommented, Apr 24, 2018

Ah, it traps focus in the sidenav when the backdrop is showing, for accessibility reasons. The input just happens to be the first focusable element in the sidenav. The focus still has to go somewhere. If there’s a different element you want it to start on you can add cdkFocusInitial to it: https://stackblitz.com/edit/angular-b26whc-2zbsv7?file=app/sidenav-mode-example.html

If you want nothing to be focused initially, you could put a tabindex="0" on the sidenav itself so it will receive the focus: https://stackblitz.com/edit/angular-b26whc-9s2ypm?file=app/sidenav-mode-example.html (I’m not so sure about the accessibility of this though, I would focus a real element if possible)

Read more comments on GitHub >

github_iconTop Results From Across the Web

On open SideBar focus on input field · Issue #10874 - GitHub
When the sidenav is opened and the user move the cursor on one of inputs the first input is always focused automatically. What...
Read more >
Why setting focus on a hidden element has caused sidebar ...
I have enabled collapse sidebar in my customize/user interface. On my Visualforce page, it works fine originally. But since my first element in ......
Read more >
How to focus active menu item in sidebar? - Stack Overflow
So when you load the page just add class="active" to the current active link of sidebar menu. Update: Server side code
Read more >
Managing Focus in React (move focus on sidebar open only)
Adding Classes. In CodePen, whatever you write in the HTML editor is what goes within the <body> tags in a basic HTML5 template....
Read more >
Set focus to input when menu is open using LayoutSideMenu
When the hamburger button is clicked, the menu opens from the left, displaying the menu with the Input box.
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