Skip to content

Commit

Permalink
fix(expansion-panel): entire body content being shown on animation st…
Browse files Browse the repository at this point in the history
…art (#10138)

Fixes expansion panels becoming `overflow: visible` as soon as their expansion animation starts, causing them to show the entire content before they're done animating. It seems like we were setting the `mat-expanded` class both through the view and manually when the animation is done.

Fixes #10134.
  • Loading branch information
crisbeto authored and tinayuangao committed Mar 1, 2018
1 parent 92ed9c8 commit b4b76bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/lib/expansion/expansion-panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[@bodyExpansion]="_getExpandedState()"
(@bodyExpansion.done)="_bodyAnimation($event)"
(@bodyExpansion.start)="_bodyAnimation($event)"
[class.mat-expanded]="expanded"
[attr.aria-labelledby]="_headerId"
[id]="id"
#body>
Expand Down
18 changes: 18 additions & 0 deletions src/lib/expansion/expansion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,24 @@ describe('MatExpansionPanel', () => {
expect(fixture.componentInstance.expanded).toBe(false);
});

it('should not set the mat-expanded class until the open animation is done', fakeAsync(() => {
const fixture = TestBed.createComponent(PanelWithContent);
const contentEl = fixture.nativeElement.querySelector('.mat-expansion-panel-content');

fixture.detectChanges();
expect(contentEl.classList).not.toContain('mat-expanded',
'Expected class not to be there on init');

fixture.componentInstance.expanded = true;
fixture.detectChanges();
expect(contentEl.classList).not.toContain('mat-expanded',
'Expected class not to be added immediately after becoming expanded');

flush();
expect(contentEl.classList).toContain('mat-expanded',
'Expected class to be added after the animation has finished');
}));

describe('disabled state', () => {
let fixture: ComponentFixture<PanelWithContent>;
let panel: HTMLElement;
Expand Down

0 comments on commit b4b76bd

Please sign in to comment.