Skip to content

Commit babf80f

Browse files
authored
fix(material/radio): disable ripples under noop animations module (#22855)
Fixes that we weren't disabling the radio button ripples when the `NoopAnimationsModule` is used.
1 parent 5ad5c57 commit babf80f

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,18 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit
131131

132132
_radioFoundation = new MDCRadioFoundation(this._radioAdapter);
133133
_classes: {[key: string]: boolean} = {};
134-
_noopAnimations: boolean;
135134

136135
constructor(@Optional() @Inject(MAT_RADIO_GROUP) radioGroup: MatRadioGroup,
137136
elementRef: ElementRef,
138137
_changeDetector: ChangeDetectorRef,
139138
_focusMonitor: FocusMonitor,
140139
_radioDispatcher: UniqueSelectionDispatcher,
141-
@Optional() @Inject(ANIMATION_MODULE_TYPE) _animationMode?: string,
140+
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,
142141
@Optional() @Inject(MAT_RADIO_DEFAULT_OPTIONS)
143142
_providerOverride?: MatRadioDefaultOptions,
144143
@Attribute('tabindex') tabIndex?: string) {
145144
super(radioGroup, elementRef, _changeDetector, _focusMonitor,
146-
_radioDispatcher, _animationMode, _providerOverride, tabIndex);
147-
this._noopAnimations = _animationMode === 'NoopAnimations';
145+
_radioDispatcher, animationMode, _providerOverride, tabIndex);
148146
this._rippleAnimation =
149147
this._noopAnimations ? {enterDuration: 0, exitDuration: 0} : RIPPLE_ANIMATION_CONFIG;
150148
}

src/material/radio/radio.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
[matRippleDisabled]="_isRippleDisabled()"
2727
[matRippleCentered]="true"
2828
[matRippleRadius]="20"
29-
[matRippleAnimation]="{enterDuration: 150}">
29+
[matRippleAnimation]="{enterDuration: _noopAnimations ? 0 : 150}">
3030

3131
<span class="mat-ripple-element mat-radio-persistent-ripple"></span>
3232
</span>

src/material/radio/radio.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,19 +486,23 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
486486
/** The native `<input type=radio>` element */
487487
@ViewChild('input') _inputElement: ElementRef<HTMLInputElement>;
488488

489+
/** Whether animations are disabled. */
490+
_noopAnimations: boolean;
491+
489492
constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>,
490493
elementRef: ElementRef,
491494
protected _changeDetector: ChangeDetectorRef,
492495
private _focusMonitor: FocusMonitor,
493496
private _radioDispatcher: UniqueSelectionDispatcher,
494-
public _animationMode?: string,
497+
animationMode?: string,
495498
private _providerOverride?: MatRadioDefaultOptions,
496499
tabIndex?: string) {
497500
super(elementRef);
498501

499502
// Assertions. Ideally these should be stripped out by the compiler.
500503
// TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
501504
this.radioGroup = radioGroup;
505+
this._noopAnimations = animationMode === 'NoopAnimations';
502506

503507
if (tabIndex) {
504508
this.tabIndex = coerceNumberProperty(tabIndex, 0);
@@ -633,7 +637,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
633637
'class': 'mat-radio-button',
634638
'[class.mat-radio-checked]': 'checked',
635639
'[class.mat-radio-disabled]': 'disabled',
636-
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
640+
'[class._mat-animation-noopable]': '_noopAnimations',
637641
'[class.mat-primary]': 'color === "primary"',
638642
'[class.mat-accent]': 'color === "accent"',
639643
'[class.mat-warn]': 'color === "warn"',

tools/public_api_guard/material/radio.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export declare abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase implements OnInit, AfterViewInit, OnDestroy, CanDisableRipple, HasTabIndex {
2-
_animationMode?: string | undefined;
32
protected _changeDetector: ChangeDetectorRef;
43
_inputElement: ElementRef<HTMLInputElement>;
4+
_noopAnimations: boolean;
55
ariaDescribedby: string;
66
ariaLabel: string;
77
ariaLabelledby: string;
@@ -22,7 +22,7 @@ export declare abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBa
2222
set required(value: boolean);
2323
get value(): any;
2424
set value(value: any);
25-
constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>, elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, _animationMode?: string | undefined, _providerOverride?: MatRadioDefaultOptions | undefined, tabIndex?: string);
25+
constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>, elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, animationMode?: string, _providerOverride?: MatRadioDefaultOptions | undefined, tabIndex?: string);
2626
_isRippleDisabled(): boolean;
2727
_markForCheck(): void;
2828
_onInputChange(event: Event): void;

0 commit comments

Comments
 (0)