Skip to content
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

fix(expansion-panel): entire body content being shown on animation start #10138

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
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