You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strange focus behaviour for dynamic matMenu content #7973
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
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 mat-select. If you really want to continue using a menu for it, you can go with the suggestion from @julianobrasil or create a custom menu panel by implementing the MatMenuPanel interface: https://github.com/angular/material2/blob/master/src/lib/menu/menu-panel.ts#L13.
Activity
julianobrasil commentedon Oct 24, 2017
As a workaround, you can do something like the code bellow as soon as the filter value change:
Plunk: http://plnkr.co/edit/hCg5lVZ1U5OFek31Vr0j?p=preview
skappler commentedon Oct 24, 2017
Thanks for the suggestion. I built a similar workaround, binding the focus() call to the onBlur event of the input
crisbeto commentedon Nov 4, 2017
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
mat-select. If you really want to continue using a menu for it, you can go with the suggestion from @julianobrasil or create a custom menu panel by implementing theMatMenuPanelinterface: https://github.com/angular/material2/blob/master/src/lib/menu/menu-panel.ts#L13.cfremgen commentedon Feb 1, 2019
Since the referenced PR looks to be dead, here's what I came up with:
angular-automatic-lock-bot commentedon Sep 10, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.