Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular material button always has a grey background anytime the modal is opened

I have an Angular Material modal that opens, but after it opens, the Go Back button, which is a mat-button, always has a gray background. However, when I click outside the modal, it disappears. How do I remove the grey background.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is Materials autoFocus property. Disable it like this:

    const dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
      width: '250px',
      data: {name: this.name, animal: this.animal},
      autoFocus: false
    });

autoFocus: false does the trick.

autoFocus: TRUE (default)
enter image description here

autoFocus: FALSE
enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading