Skip to content

Commit fa60fe4

Browse files
crisbetoandrewseguin
authored andcommitted
fix(select): disable all animations when using NoopAnimationsModule (#11594)
Disables all the CSS-based transition in `mat-select` when it's inside something with the `NoopAnimationsModule`. Relates to #10590.
1 parent f042068 commit fa60fe4

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import '../../style/checkbox-common';
2+
@import '../../style/noop-animation';
23

34
// Padding inside of a pseudo checkbox.
45
$_mat-pseudo-checkbox-padding: $mat-checkbox-border-width * 2;
@@ -34,6 +35,12 @@ $_mat-pseudo-checkmark-size: $mat-checkbox-size - (2 * $_mat-pseudo-checkbox-pad
3435
&.mat-pseudo-checkbox-checked, &.mat-pseudo-checkbox-indeterminate {
3536
border-color: transparent;
3637
}
38+
39+
@include _noop-animation {
40+
&::after {
41+
transition: none;
42+
}
43+
}
3744
}
3845

3946
.mat-pseudo-checkbox-disabled {

src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Component, ViewEncapsulation, Input, ChangeDetectionStrategy} from '@angular/core';
9+
import {
10+
Component,
11+
ViewEncapsulation,
12+
Input,
13+
ChangeDetectionStrategy,
14+
Inject,
15+
Optional,
16+
} from '@angular/core';
17+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
1018

19+
/**
20+
* Possible states for a pseudo checkbox.
21+
* @docs-private
22+
*/
1123
export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate';
1224

1325
/**
@@ -35,6 +47,7 @@ export type MatPseudoCheckboxState = 'unchecked' | 'checked' | 'indeterminate';
3547
'[class.mat-pseudo-checkbox-indeterminate]': 'state === "indeterminate"',
3648
'[class.mat-pseudo-checkbox-checked]': 'state === "checked"',
3749
'[class.mat-pseudo-checkbox-disabled]': 'disabled',
50+
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
3851
},
3952
})
4053
export class MatPseudoCheckbox {
@@ -43,4 +56,6 @@ export class MatPseudoCheckbox {
4356

4457
/** Whether the checkbox is disabled. */
4558
@Input() disabled: boolean = false;
59+
60+
constructor(@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) { }
4661
}

src/lib/core/style/_noop-animation.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
@at-root ._mat-animation-noopable#{&} {
1818
transition: none;
1919
animation: none;
20+
@content;
2021
}
2122
}

src/lib/select/select.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
105105
transition: color $swift-ease-out-duration $swift-ease-out-duration / 3
106106
$swift-ease-out-timing-function;
107107

108+
._mat-animation-noopable & {
109+
transition: none;
110+
}
111+
108112
.mat-form-field-hide-placeholder & {
109113
color: transparent;
110114

0 commit comments

Comments
 (0)