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

1

10

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

Stackblitz example

Toor answered 12/2, 2019 at 7:22 Comment(1)
you can add "tabIndex=-1" to each buttonMccaskill
S
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 
});
Seamus answered 12/2, 2019 at 7:30 Comment(1)
The word autofocus in the phraseautofocus = false should be autoFocus. The letter f should be capitalized.Spickandspan

© 2022 - 2024 — McMap. All rights reserved.