10

When we place button inside angular material dialog it is auto focussing first button in that modal.

Stackblitz example

Khai Kiong
  • 371
  • 2
  • 13
mani singh
  • 241
  • 2
  • 4
  • 9

1 Answers1

19

You can add the autofocus = false properties to the dialog to disable the auto focus.

Example as below:

const dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
   width: '250px',
   data: {name: this.name, animal: this.animal},
   autoFocus: false 
});
Khai Kiong
  • 371
  • 2
  • 13
  • The word `autofocus` in the phrase`autofocus = false` should be `autoFocus`. The letter f should be capitalized. – Duke Caesar Oct 10 '22 at 18:34