Skip to content

Commit 35b66f9

Browse files
crisbetotinayuangao
authored andcommitted
fix(expansion-panel): entire body content being shown on animation start (#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.
1 parent cbe11d4 commit 35b66f9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/lib/expansion/expansion-panel.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[@bodyExpansion]="_getExpandedState()"
55
(@bodyExpansion.done)="_bodyAnimation($event)"
66
(@bodyExpansion.start)="_bodyAnimation($event)"
7-
[class.mat-expanded]="expanded"
87
[attr.aria-labelledby]="_headerId"
98
[id]="id"
109
#body>

src/lib/expansion/expansion.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,24 @@ describe('MatExpansionPanel', () => {
246246
expect(fixture.componentInstance.expanded).toBe(false);
247247
});
248248

249+
it('should not set the mat-expanded class until the open animation is done', fakeAsync(() => {
250+
const fixture = TestBed.createComponent(PanelWithContent);
251+
const contentEl = fixture.nativeElement.querySelector('.mat-expansion-panel-content');
252+
253+
fixture.detectChanges();
254+
expect(contentEl.classList).not.toContain('mat-expanded',
255+
'Expected class not to be there on init');
256+
257+
fixture.componentInstance.expanded = true;
258+
fixture.detectChanges();
259+
expect(contentEl.classList).not.toContain('mat-expanded',
260+
'Expected class not to be added immediately after becoming expanded');
261+
262+
flush();
263+
expect(contentEl.classList).toContain('mat-expanded',
264+
'Expected class to be added after the animation has finished');
265+
}));
266+
249267
describe('disabled state', () => {
250268
let fixture: ComponentFixture<PanelWithContent>;
251269
let panel: HTMLElement;

0 commit comments

Comments
 (0)