Skip to content

fix(chips): disable all animations when using NoopAnimationsModule #11546

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 13, 2019
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
12 changes: 10 additions & 2 deletions src/material/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
} from '@angular/material/core';
import {Subject} from 'rxjs';
import {take} from 'rxjs/operators';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';


/** Represents an event fired on an individual `mat-chip`. */
Expand Down Expand Up @@ -105,6 +106,7 @@ export class MatChipTrailingIcon {}
'[class.mat-chip-with-avatar]': 'avatar',
'[class.mat-chip-with-trailing-icon]': 'trailingIcon || removeIcon',
'[class.mat-chip-disabled]': 'disabled',
'[class._mat-animation-noopable]': '_animationsDisabled',
'[attr.disabled]': 'disabled || null',
'[attr.aria-disabled]': 'disabled.toString()',
'[attr.aria-selected]': 'ariaSelected',
Expand Down Expand Up @@ -139,6 +141,9 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
/** Whether the chip has focus. */
_hasFocus: boolean = false;

/** Whether animations for the chip are enabled. */
_animationsDisabled: boolean;

/** Whether the chip list is selectable */
chipListSelectable: boolean = true;

Expand Down Expand Up @@ -224,18 +229,21 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
this.selected.toString() : null;
}

constructor(public _elementRef: ElementRef,
constructor(public _elementRef: ElementRef<HTMLElement>,
private _ngZone: NgZone,
platform: Platform,
@Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS)
globalRippleOptions: RippleGlobalOptions | null) {
globalRippleOptions: RippleGlobalOptions | null,
// @breaking-change 8.0.0 `animationMode` parameter to become required.
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
super(_elementRef);

this._addHostClassName();

this._chipRipple = new RippleRenderer(this, _ngZone, _elementRef, platform);
this._chipRipple.setupTriggerEvents(_elementRef.nativeElement);
this.rippleConfig = globalRippleOptions || {};
this._animationsDisabled = animationMode === 'NoopAnimations';
}

_addHostClassName() {
Expand Down
2 changes: 2 additions & 0 deletions src/material/chips/chips.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '../core/style/variables';
@import '../core/style/elevation';
@import '../core/style/layout-common';
@import '../core/style/noop-animation';
@import '../../cdk/a11y/a11y';

$mat-chip-min-height: 32px;
Expand Down Expand Up @@ -36,6 +37,7 @@ $mat-chip-remove-size: 18px;

.mat-standard-chip {
@include mat-elevation-transition;
@include _noop-animation;
display: inline-flex;
padding: $mat-chip-vertical-padding $mat-chip-horizontal-padding;
border-radius: 16px;
Expand Down
5 changes: 3 additions & 2 deletions tools/public_api_guard/material/chips.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export declare const MAT_CHIPS_DEFAULT_OPTIONS: InjectionToken<MatChipsDefaultOptions>;

export declare class MatChip extends _MatChipMixinBase implements FocusableOption, OnDestroy, CanColor, CanDisable, CanDisableRipple, RippleTarget {
_animationsDisabled: boolean;
_chipListMultiple: boolean;
_elementRef: ElementRef;
_elementRef: ElementRef<HTMLElement>;
_hasFocus: boolean;
readonly _onBlur: Subject<MatChipEvent>;
readonly _onFocus: Subject<MatChipEvent>;
Expand All @@ -24,7 +25,7 @@ export declare class MatChip extends _MatChipMixinBase implements FocusableOptio
readonly selectionChange: EventEmitter<MatChipSelectionChange>;
trailingIcon: MatChipTrailingIcon;
value: any;
constructor(_elementRef: ElementRef, _ngZone: NgZone, platform: Platform, globalRippleOptions: RippleGlobalOptions | null);
constructor(_elementRef: ElementRef<HTMLElement>, _ngZone: NgZone, platform: Platform, globalRippleOptions: RippleGlobalOptions | null, animationMode?: string);
_addHostClassName(): void;
_blur(): void;
_handleClick(event: Event): void;
Expand Down