Skip to content

Commit

Permalink
fix(multiple): touch targets not excluded in densities lower than -2 (#…
Browse files Browse the repository at this point in the history
…25108)

Fixes that touch targets were being removed only on `-2` or `minimum` densities, but not anything lower.

Also moves the check into a common mixin so we only have one place where it needs to be changed.

(cherry picked from commit 6369204)
  • Loading branch information
crisbeto committed Jun 23, 2022
1 parent a1f6f66 commit 301f6b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@use 'sass:map';
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '@material/theme/theme-color' as mdc-theme-color;
@use '../mdc-core/mdc-helpers/mdc-helpers';

@mixin _ripple-color($color) {
--mat-mdc-button-persistent-ripple-color: #{$color};
Expand Down Expand Up @@ -53,7 +54,7 @@

// Hides the touch target on lower densities.
@mixin touch-target-density($scale) {
@if ($scale == -2 or $scale == 'minimum') {
@include mdc-helpers.if-touch-targets-unsupported($scale) {
.mat-mdc-button-touch-target {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
);
}

@if ($density-scale == -2 or $density-scale == 'minimum') {
@include mdc-helpers.if-touch-targets-unsupported($density-scale) {
.mat-mdc-checkbox-touch-target {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/theme/css' as mdc-theme-css;
@use 'sass:map';
@use 'sass:meta';

// A set of standard queries to use with MDC's queryable mixins.
$mat-base-styles-query: mdc-feature-targeting.without(mdc-feature-targeting.any(color, typography));
Expand Down Expand Up @@ -211,3 +212,10 @@ $mat-typography-mdc-level-mappings: (
@content;
mdc-theme-css.$enable-fallback-declarations: $previous-value;
}

// Excludes the passed-in CSS content if the layout is too dense to supports touch targets.
@mixin if-touch-targets-unsupported($scale) {
@if ($scale == 'minimum' or (meta.type-of($scale) == 'number' and $scale < -1)) {
@content;
}
}
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-radio/_radio-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
@include mdc-radio-theme.density($density-scale, $query: mdc-helpers.$mat-base-styles-query);
}

@if ($density-scale == -2 or $density-scale == 'minimum') {
@include mdc-helpers.if-touch-targets-unsupported($density-scale) {
.mat-mdc-radio-touch-target {
display: none;
}
Expand Down

0 comments on commit 301f6b0

Please sign in to comment.