Skip to content

Commit 6cf4e0d

Browse files
committed
fix(material-experimental/mdc-button): density styles being overwritten by structural styles
The button's density styles currently have the same specificity as the structural styles which means that they'll usually be overwritten, unless they're nested inside another selector. These changes add more specificity so that the density always has precedence. Fixes #22728.
1 parent 3284496 commit 6cf4e0d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/material-experimental/mdc-button/_button-theme.scss

+5-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,11 @@
158158
.mat-mdc-raised-button,
159159
.mat-mdc-unelevated-button,
160160
.mat-mdc-outlined-button {
161-
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
162-
@include button-theme-private.touch-target-density($density-scale);
161+
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
162+
&.mat-mdc-button-base {
163+
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
164+
@include button-theme-private.touch-target-density($density-scale);
165+
}
163166
}
164167
}
165168

src/material-experimental/mdc-button/_icon-button-theme.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656

5757
@mixin density($config-or-theme) {
5858
$density-scale: theming.get-density-config($config-or-theme);
59-
.mat-mdc-icon-button {
59+
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
60+
.mat-mdc-icon-button.mat-mdc-button-base {
6061
@include mdc-icon-button.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
6162
@include button-theme-private.touch-target-density($density-scale);
6263
}

0 commit comments

Comments
 (0)