Skip to content

Commit f116000

Browse files
authored
fix(material-experimental/mdc-radio): not removing animations when noop animations are enabled (#22651)
Fixes that the MDC-based radio button didn't disable its animations when noop animations were turned on.
1 parent cd87b38 commit f116000

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/material-experimental/mdc-radio/radio.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@use '../../cdk/a11y';
66
@use '../../material/core/style/layout-common';
77

8-
@include mdc-radio.without-ripple($query: mdc-helpers.$mat-base-styles-query);
8+
@include mdc-radio.without-ripple($query: mdc-helpers.$mat-base-styles-without-animation-query);
99
@include mdc-form-field.core-styles($query: mdc-helpers.$mat-base-styles-query);
1010

1111
// This is necessary because we do not depend on MDC's ripple, but have our own that should be
@@ -21,6 +21,10 @@
2121
}
2222
}
2323

24+
.mat-mdc-radio-button:not(._mat-animation-noopable) {
25+
@include mdc-radio.without-ripple($query: animation);
26+
}
27+
2428
// Note that this creates a square box around the circle, however it's consistent with
2529
// how IE/Edge treat native radio buttons in high contrast mode. We can't turn the border
2630
// into a dotted one, because it's too thick which causes the circles to look off.

src/material-experimental/mdc-radio/radio.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export class MatRadioGroup extends _MatRadioGroupBase<MatRadioButton> {
9797
'[class.mat-primary]': 'color === "primary"',
9898
'[class.mat-accent]': 'color === "accent"',
9999
'[class.mat-warn]': 'color === "warn"',
100+
'[class._mat-animation-noopable]': '_noopAnimations',
100101
// Needs to be removed since it causes some a11y issues (see #21266).
101102
'[attr.tabindex]': 'null',
102103
'[attr.aria-label]': 'null',
@@ -126,10 +127,11 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit
126127
};
127128

128129
/** Configuration for the underlying ripple. */
129-
_rippleAnimation: RippleAnimationConfig = RIPPLE_ANIMATION_CONFIG;
130+
_rippleAnimation: RippleAnimationConfig;
130131

131132
_radioFoundation = new MDCRadioFoundation(this._radioAdapter);
132133
_classes: {[key: string]: boolean} = {};
134+
_noopAnimations: boolean;
133135

134136
constructor(@Optional() @Inject(MAT_RADIO_GROUP) radioGroup: MatRadioGroup,
135137
elementRef: ElementRef,
@@ -142,6 +144,9 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit
142144
@Attribute('tabindex') tabIndex?: string) {
143145
super(radioGroup, elementRef, _changeDetector, _focusMonitor,
144146
_radioDispatcher, _animationMode, _providerOverride, tabIndex);
147+
this._noopAnimations = _animationMode === 'NoopAnimations';
148+
this._rippleAnimation =
149+
this._noopAnimations ? {enterDuration: 0, exitDuration: 0} : RIPPLE_ANIMATION_CONFIG;
145150
}
146151

147152
ngAfterViewInit() {

0 commit comments

Comments
 (0)