Skip to content

Commit

Permalink
fix(material-experimental/mdc-button): density styles being overwritt…
Browse files Browse the repository at this point in the history
…en 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.
  • Loading branch information
crisbeto committed Jun 14, 2021
1 parent 3284496 commit 6cf4e0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/material-experimental/mdc-button/_button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@
.mat-mdc-raised-button,
.mat-mdc-unelevated-button,
.mat-mdc-outlined-button {
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
@include button-theme-private.touch-target-density($density-scale);
// Use `mat-mdc-button-base` to increase the specificity over the button's structural styles.
&.mat-mdc-button-base {
@include mdc-button-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
@include button-theme-private.touch-target-density($density-scale);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/material-experimental/mdc-button/_icon-button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@

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

0 comments on commit 6cf4e0d

Please sign in to comment.