Skip to content

fix(expansion): disable all animations when using NoopAnimationsModule #12855

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
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: 6 additions & 0 deletions src/lib/expansion/expansion-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
@include cdk-high-contrast {
outline: solid 1px;
}

&.ng-animate-disabled,
.ng-animate-disabled &,
&._mat-animation-noopable {
transition: none;
}
}

.mat-expansion-panel-content {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/expansion/expansion-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
ViewChild,
} from '@angular/core';
import {DOCUMENT} from '@angular/common';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
import {Subject} from 'rxjs';
import {filter, startWith, take} from 'rxjs/operators';
import {matExpansionAnimations} from './expansion-animations';
Expand Down Expand Up @@ -73,6 +74,7 @@ let uniqueId = 0;
host: {
'class': 'mat-expansion-panel',
'[class.mat-expanded]': 'expanded',
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
'[class.mat-expansion-panel-spacing]': '_hasSpacing()',
}
})
Expand Down Expand Up @@ -121,7 +123,9 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
_changeDetectorRef: ChangeDetectorRef,
_uniqueSelectionDispatcher: UniqueSelectionDispatcher,
private _viewContainerRef: ViewContainerRef,
@Inject(DOCUMENT) _document?: any) {
// @breaking-change 8.0.0 _document and _animationMode to be made required
@Inject(DOCUMENT) _document?: any,
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
super(accordion, _changeDetectorRef, _uniqueSelectionDispatcher);
this.accordion = accordion;
this._document = _document;
Expand Down