Angular Material SnackBar `onAction()` method doesn't trigger

Viewed 454

I have a problem with Angular Material SnackBar onAction() method, it doesn't trigger after the button is clicked. I've opened SnackBar and subscribed to onAction, afterDismissed and afterOpened methods. Other methods are triggered, but not onAction. Does anyone know what should I do? I have this problem since last Angular update from 9 to 11.

constructor(public snackBar: MatSnackBar) {}

private openSnackBar() {
  let mySnackBar: MatSnackBarRef<TextOnlySnackBar> = this.snackBar.open('Message', 'Close');
    mySnackBar.afterDismissed().subscribe((matSnackBarDismiss: MatSnackBarDismiss) => {
      console.log('afterDismissed');
    });
    mySnackBar.onAction().subscribe(() => {
      console.log('onAction');
      mySnackBar.dismiss();
    });
    mySnackBar.afterOpened().subscribe(() => {
      console.log('afterOpened');
    });
  }
}
1 Answers

It was a problem with internal CSS. Probably somebody removed some CSS property (I think it was pointer-events), and it was included in the Angular update. I fixed a local CSS and it works now.

Related