Open Aljumaily opened 1 week ago
What color are you expecting for the menu and option exactly? I just tried it out and it seems like they have the proper color based on the passed-in palettes:
The issue is apparent when the project has two themes. Suppose that the light theme is applied in :root{ ... }
, then it will work fine and the correct colours will be applied. Now, suppose a toggle button is available to switch to dark theme, then other components, such as mat-button
, mat-button-toggle-group
, etc. will have the correct theme applied. However, mat-menu
and mat-option
will still follow the light theme style. So, if the toggle button is kept on being clicked to change from to light theme to dark theme and vice-versa, mat-menu
and mat-option
will apply the same theme found in :root{ ... }
, regardless of which theme is currently selected.
What element are you applying the theme classes to? I suspect that it isn't being set on the .cdk-overlay-container
.
I am applying the themes on all of the components as am using the following commands:
@include mat.all-component-themes($light-theme);
@include mat.all-component-typographies($light-theme);
@include mat.system-level-typography($light-theme);
@include mat.system-level-colors($light-theme);
As for using .cdk-overlay-container
, unfortunately, it doesn't work as expected. It will change to the theme specified in :root { ... }
. Switching the theme from light to dark or vice-versa will show one and only one colour.
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I have the following working theme switcher code:
All of the
mat-...
work by default exceptmat-menu
andmat-option
.I create a custom mixin to manually update the colour of
mat-menu
but it only works for the light theme because it is placed in:root{ }
. Otherwise, it will not be triggered. All of the packages are up to date and no errors occur. The html code used is:Reproduction
There is no StackBlitz link because the link of the documentation doesn't work with Angular 18.0.6.
Expected Behavior
The expected behaviour is to have both
mat-menu
andmat-option
to follow automatically the theme, without the need of custom mixins.Actual Behavior
The
mat-menu
is updated once because the mixin call was placed in:root{}
, andmat-option
just doesn't work.Environment
Angular CLI: 18.0.6 Node: 20.14.0 Package Manager: npm 10.8.1 OS: darwin arm64
Angular: 18.0.5 ... animations, cdk, common, compiler, compiler-cli, core, forms ... material, platform-browser, platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.1800.6 @angular-devkit/build-angular 18.0.6 @angular-devkit/core 18.0.6 @angular-devkit/schematics 18.0.6 @angular/cli 18.0.6 @schematics/angular 18.0.6 rxjs 7.8.1 typescript 5.4.5 zone.js 0.14.7