Skip to content

Commit affc893

Browse files
authored
fix: unable to set expanded or collapsed height in expansion panel (#19322)
For the density system, we reworked the expansion panel to no longer rely on Angular animations. Looks like the refactoring missed that units are already set for the `expandedHeight` and `collapsedHeight` inputs. This hasn't been catched in any unit test, so tests are updated to catch this now.
1 parent 369fb79 commit affc893

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/material/expansion/expansion-panel-header.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ export class MatExpansionPanelHeader implements OnDestroy, FocusableOption {
161161
_getHeaderHeight(): string|null {
162162
const isExpanded = this._isExpanded();
163163
if (isExpanded && this.expandedHeight) {
164-
return `${this.expandedHeight}px`;
164+
return this.expandedHeight;
165165
} else if (!isExpanded && this.collapsedHeight) {
166-
return `${this.collapsedHeight}px`;
166+
return this.collapsedHeight;
167167
}
168168
return null;
169169
}

src/material/expansion/expansion.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ describe('MatExpansionPanel', () => {
351351
expect(panel.componentInstance.hideToggle).toBe(true);
352352
expect(header.componentInstance.expandedHeight).toBe('10px');
353353
expect(header.componentInstance.collapsedHeight).toBe('16px');
354+
expect(header.nativeElement.style.height).toBe('16px');
355+
356+
fixture.componentInstance.expanded = true;
357+
fixture.detectChanges();
358+
expect(header.nativeElement.style.height).toBe('10px');
354359
});
355360

356361
describe('disabled state', () => {

0 commit comments

Comments
 (0)