On open SideBar focus on input field
See original GitHub issueBug, 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:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for you answer, now it’s clear for me. Have a good day !
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.htmlIf 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)