Skip to content

Commit a3bb573

Browse files
crisbetommalerba
authored andcommitted
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. (cherry picked from commit babf80f)
1 parent cfc4ad9 commit a3bb573

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
@@ -489,19 +489,23 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
489489
/** The native `<input type=radio>` element */
490490
@ViewChild('input') _inputElement: ElementRef<HTMLInputElement>;
491491

492+
/** Whether animations are disabled. */
493+
_noopAnimations: boolean;
494+
492495
constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>,
493496
elementRef: ElementRef,
494497
protected _changeDetector: ChangeDetectorRef,
495498
private _focusMonitor: FocusMonitor,
496499
private _radioDispatcher: UniqueSelectionDispatcher,
497-
public _animationMode?: string,
500+
animationMode?: string,
498501
private _providerOverride?: MatRadioDefaultOptions,
499502
tabIndex?: string) {
500503
super(elementRef);
501504

502505
// Assertions. Ideally these should be stripped out by the compiler.
503506
// TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
504507
this.radioGroup = radioGroup;
508+
this._noopAnimations = animationMode === 'NoopAnimations';
505509

506510
if (tabIndex) {
507511
this.tabIndex = coerceNumberProperty(tabIndex, 0);
@@ -636,7 +640,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
636640
'class': 'mat-radio-button',
637641
'[class.mat-radio-checked]': 'checked',
638642
'[class.mat-radio-disabled]': 'disabled',
639-
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
643+
'[class._mat-animation-noopable]': '_noopAnimations',
640644
'[class.mat-primary]': 'color === "primary"',
641645
'[class.mat-accent]': 'color === "accent"',
642646
'[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)