Skip to content

Commit cc5326c

Browse files
authored
fix(material/core): noop animations not applying to selector lists (#24904)
The way the `private-animation-noop` mixin was written meant that if it was included in a list of selectors, it would only be applied to the first selector in the list. This caused some animations in the MDC button not to be disabled. These changes simplify the mixin, because the old approach was only relevant for on case in the progress spinner that we can write out manually instead.
1 parent 32a8b38 commit cc5326c

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/material/core/style/_private.scss

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,11 @@
2222
// NOTE: Currently this mixin should only be used with components that do not
2323
// have any projected content.
2424
@mixin private-animation-noop() {
25-
// @at-root is used to steps outside of the hierarchy of the scss rules. This is
26-
// done to allow a class to be added to be added to base of the scss nesting
27-
// context.
28-
// For example:
29-
// .my-root {
30-
// .my-subclass {
31-
// @include mat-private-animation-noop();
32-
// }
33-
// }
34-
// results in:
35-
// ._mat-animation-noopable.my-root .my-subclass { ... }
36-
@at-root ._mat-animation-noopable#{&} {
37-
transition: none;
38-
animation: none;
25+
&._mat-animation-noopable {
26+
// Use !important here since we don't know what context this mixin will
27+
// be included in and MDC can have some really specific selectors.
28+
transition: none !important;
29+
animation: none !important;
3930
@content;
4031
}
4132
}

src/material/progress-spinner/progress-spinner.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@use '@angular/cdk';
22

33
@use '../core/style/variables';
4-
@use '../core/style/private';
54

65
$_default-radius: 45px;
76
$_default-circumference: variables.$pi * $_default-radius * 2;
@@ -24,7 +23,6 @@ $_default-circumference: variables.$pi * $_default-radius * 2;
2423
}
2524

2625
circle {
27-
@include private.private-animation-noop();
2826
fill: transparent;
2927
transition: stroke-dashoffset 225ms linear;
3028

@@ -37,22 +35,27 @@ $_default-circumference: variables.$pi * $_default-radius * 2;
3735
}
3836
}
3937

40-
&.mat-progress-spinner-indeterminate-animation[mode='indeterminate'] {
38+
&[mode='indeterminate'] {
4139
svg {
42-
@include private.private-animation-noop();
4340
animation: mat-progress-spinner-linear-rotate variables.$swift-ease-in-out-duration * 4
4441
linear infinite;
4542
}
4643

4744
circle {
48-
@include private.private-animation-noop();
4945
transition-property: stroke;
5046
// Note: we multiply the duration by 8, because the animation is spread out in 8 stages.
5147
animation-duration: variables.$swift-ease-in-out-duration * 8;
5248
animation-timing-function: variables.$ease-in-out-curve-function;
5349
animation-iteration-count: infinite;
5450
}
5551
}
52+
53+
&._mat-animation-noopable {
54+
svg, circle {
55+
animation: none;
56+
transition: none;
57+
}
58+
}
5659
}
5760

5861

0 commit comments

Comments
 (0)