-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Strange focus behaviour for dynamic matMenu content #7973
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
Comments
As a workaround, you can do something like the code bellow as soon as the filter value change: @ViewChild(MatInput) input = MatInput;
...
setTimeout(() => this.input._elementRef.nativeElement.focus(), 200); |
Thanks for the suggestion. I built a similar workaround, binding the focus() call to the onBlur event of the input |
Menus aren't really meant to be used for filtering, that's why focus ends up being stolen away from the input. I think what you're looking for is something like this which will be added to |
Since the referenced PR looks to be dead, here's what I came up with:
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
No menu item should be selected automatically
What is the current behavior?
I have a matMenu which contains an input field which can be used to filter the menu items. After entering the first character of the filter string, the input loses focus and one of the menu items is selected. After re-focussing the input and typing more, it behaves as expected
What are the steps to reproduce?
See this plunker http://plnkr.co/edit/dc3vNd4viVg2jM6Errtm?p=preview
Is there anything else we should know?
It worked on angular 2.4.5 and material 2.0.0-beta.1
Was broken after upgrading to 4.4.4 and beta.12
The text was updated successfully, but these errors were encountered: