mani singh
mani singh

Reputation: 251

How to remove auto focus on button inside angular material modal?

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

Stackblitz example

Upvotes: 10

Views: 9590

Answers (1)

Khai Kiong
Khai Kiong

Reputation: 461

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 
});

Upvotes: 19

Related Questions