-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Autocomplete focus when inside a dialog #7972
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
I'm having exactly the same issue - not that that helps you as I haven't found a workaround yet. Sorry |
This is working by design. https://github.com/angular/material2/blob/master/src/lib/dialog/dialog-container.ts#L150 When the dialog opens it needs to switch the focus from the button that initiated the dialog the a focusable element in the dialog ( your input in this case ). You can get around this by adding |
Cheers this works for me. |
Workaround does work a bit of a hack as it's a shame this then means the autocomplete cannot be tabbed to |
Restores focus to the element that was focused before the dialog opened. This kind is false in this situation but yeah I agree it's a workaround. |
Depending on your situation, a better solution may be to add <div mat-dialog-content cdk-focus-initial> ... </div> https://stackblitz.com/edit/angular-tksjrg?file=app%2Ftoolbar.html |
That's great thank you! |
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. |
Uh oh!
There was an error while loading. Please reload this page.
Bug, feature request, or proposal:
Bug
What is the expected behavior?
When opening a dialog the autocomplete doesn't have focus.
Expected: https://angular-qgx8sh.stackblitz.io/
What is the current behavior?
When opening a dialog my autocomplete get focussed.
What are the steps to reproduce?
Just open a dialog with data of the states in it:
this.dialog.open(SlideInToolbar, { width: '150px', data: { states: this.states } });
And inside the dialog an autocomplete with:
<mat-option *ngFor="let item of data.states" [value]="item.name">
https://angular-omzvev.stackblitz.io/
What is the use-case or motivation for changing an existing behavior?
I want to implement a autocomplete in a dialog without focus.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 4.4.4
Material: 2.0.0-beta.12
The text was updated successfully, but these errors were encountered: