Skip to content

fix(material/radio): disable ripples under noop animations module #22855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/material-experimental/mdc-radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,18 @@ export class MatRadioButton extends _MatRadioButtonBase implements AfterViewInit

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

constructor(@Optional() @Inject(MAT_RADIO_GROUP) radioGroup: MatRadioGroup,
elementRef: ElementRef,
_changeDetector: ChangeDetectorRef,
_focusMonitor: FocusMonitor,
_radioDispatcher: UniqueSelectionDispatcher,
@Optional() @Inject(ANIMATION_MODULE_TYPE) _animationMode?: string,
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,
@Optional() @Inject(MAT_RADIO_DEFAULT_OPTIONS)
_providerOverride?: MatRadioDefaultOptions,
@Attribute('tabindex') tabIndex?: string) {
super(radioGroup, elementRef, _changeDetector, _focusMonitor,
_radioDispatcher, _animationMode, _providerOverride, tabIndex);
this._noopAnimations = _animationMode === 'NoopAnimations';
_radioDispatcher, animationMode, _providerOverride, tabIndex);
this._rippleAnimation =
this._noopAnimations ? {enterDuration: 0, exitDuration: 0} : RIPPLE_ANIMATION_CONFIG;
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/radio/radio.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[matRippleDisabled]="_isRippleDisabled()"
[matRippleCentered]="true"
[matRippleRadius]="20"
[matRippleAnimation]="{enterDuration: 150}">
[matRippleAnimation]="{enterDuration: _noopAnimations ? 0 : 150}">

<span class="mat-ripple-element mat-radio-persistent-ripple"></span>
</span>
Expand Down
8 changes: 6 additions & 2 deletions src/material/radio/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,19 +486,23 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
/** The native `<input type=radio>` element */
@ViewChild('input') _inputElement: ElementRef<HTMLInputElement>;

/** Whether animations are disabled. */
_noopAnimations: boolean;

constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>,
elementRef: ElementRef,
protected _changeDetector: ChangeDetectorRef,
private _focusMonitor: FocusMonitor,
private _radioDispatcher: UniqueSelectionDispatcher,
public _animationMode?: string,
animationMode?: string,
private _providerOverride?: MatRadioDefaultOptions,
tabIndex?: string) {
super(elementRef);

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

if (tabIndex) {
this.tabIndex = coerceNumberProperty(tabIndex, 0);
Expand Down Expand Up @@ -633,7 +637,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple
'class': 'mat-radio-button',
'[class.mat-radio-checked]': 'checked',
'[class.mat-radio-disabled]': 'disabled',
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
'[class._mat-animation-noopable]': '_noopAnimations',
'[class.mat-primary]': 'color === "primary"',
'[class.mat-accent]': 'color === "accent"',
'[class.mat-warn]': 'color === "warn"',
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/material/radio.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export declare abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase implements OnInit, AfterViewInit, OnDestroy, CanDisableRipple, HasTabIndex {
_animationMode?: string | undefined;
protected _changeDetector: ChangeDetectorRef;
_inputElement: ElementRef<HTMLInputElement>;
_noopAnimations: boolean;
ariaDescribedby: string;
ariaLabel: string;
ariaLabelledby: string;
Expand All @@ -22,7 +22,7 @@ export declare abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBa
set required(value: boolean);
get value(): any;
set value(value: any);
constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>, elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, _animationMode?: string | undefined, _providerOverride?: MatRadioDefaultOptions | undefined, tabIndex?: string);
constructor(radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>, elementRef: ElementRef, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor, _radioDispatcher: UniqueSelectionDispatcher, animationMode?: string, _providerOverride?: MatRadioDefaultOptions | undefined, tabIndex?: string);
_isRippleDisabled(): boolean;
_markForCheck(): void;
_onInputChange(event: Event): void;
Expand Down