Description
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
14
Description
I have a snack bar with a custom component. In this component I have a custom action button. I want this button to be in the primary color, so I set the color
attribute of the button to "primary"
:
<button mat-button color="primary" matSnackBarAction>
My custom action
</button>
Before MDC, the color
attribute was respected, and the button changed its color accordingly. After MDC migration, the button stays in the accent color regardless of what color
is set.
Reproduction
StackBlitz link: https://stackblitz.com/edit/kbv7nf
Steps to reproduce:
- Create a custom snack bar component / template
- Add an action button to the custom snack bar
- Set the
color
of the action button to"primary"
Expected Behavior
The button is displayed in the primary color
Actual Behavior
The button is displayed in the accent color
Environment
- Angular: 16
- CDK/Material: 16
- Browser(s): all
- Operating System (e.g. Windows, macOS, Ubuntu): all
Further notes
I investigated the issue a bit, and it seems like using the matSnackBarAction
directive overrides the color of the button. Omitting this directive fixes the issue, however the docs state that this directive should be used.