I have problem with focus in Angular Material. When I want open mat-menu, button after click is not actived or focused, and has default color. After closed mat-menu, button is again focused/activated. Where is the problem?
Example source:
How can I resolve this problem? Thanks!
What you need is to use events of mat-menu. You can simply trick by applying class when menu is open.
<button mat-icon-button [matMenuTriggerFor]="menuUserPhoto" class="user-photo__btn" #t="matMenuTrigger" [class.opened]="t.menuOpen">
CSS
.opened {
background: darkcyan;
color: white;
opacity: 1;
}
Working stackblits as follows.