Skip to content

Commit

Permalink
fix(material/slide-toggle): don't trigger active state for entire con…
Browse files Browse the repository at this point in the history
…tainer (#29514)

Fixes that the slide toggle was triggering the `:active` styles for the entire container, even though only parts of it are interactive.

Fixes #29483.

(cherry picked from commit 5892acf)
  • Loading branch information
crisbeto committed Jul 30, 2024
1 parent 85409f5 commit d7d82e1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/material/slide-toggle/slide-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@use '../core/tokens/m2/mat/switch' as tokens-mat-switch;
@use '../core/tokens/m2/mdc/switch' as tokens-mdc-switch;
@use '../core/tokens/token-utils';
@use '../core/style/vendor-prefixes';

$_mdc-slots: (tokens-mdc-switch.$prefix, tokens-mdc-switch.get-token-slots());
$_mat-slots: (tokens-mat-switch.$prefix, tokens-mat-switch.get-token-slots());
Expand Down Expand Up @@ -250,16 +251,16 @@ $_mat-slots: (tokens-mat-switch.$prefix, tokens-mat-switch.get-token-slots());
@include token-utils.create-token-slot(height, with-icon-handle-size);
}

.mat-mdc-slide-toggle:active .mdc-switch:not(.mdc-switch--disabled) & {
.mat-mdc-slide-toggle .mdc-switch:active:not(.mdc-switch--disabled) & {
@include token-utils.create-token-slot(width, pressed-handle-size);
@include token-utils.create-token-slot(height, pressed-handle-size);
}

.mat-mdc-slide-toggle:active .mdc-switch--selected:not(.mdc-switch--disabled) & {
.mat-mdc-slide-toggle .mdc-switch--selected:active:not(.mdc-switch--disabled) & {
@include token-utils.create-token-slot(margin, selected-pressed-handle-horizontal-margin);
}

.mat-mdc-slide-toggle:active .mdc-switch--unselected:not(.mdc-switch--disabled) & {
.mat-mdc-slide-toggle .mdc-switch--unselected:active:not(.mdc-switch--disabled) & {
@include token-utils.create-token-slot(margin, unselected-pressed-handle-horizontal-margin);
}

Expand Down Expand Up @@ -479,6 +480,7 @@ $_mat-slots: (tokens-mat-switch.$prefix, tokens-mat-switch.get-token-slots());
}

.mat-mdc-slide-toggle {
@include vendor-prefixes.user-select(none);
display: inline-block;
-webkit-tap-highlight-color: transparent;

Expand Down

0 comments on commit d7d82e1

Please sign in to comment.