Skip to content

Commit 8df25c9

Browse files
committed
fix(expansion-panel): appearing as open if placed inside animating element
This is an alternate approach to #13888 which had to be reverted due to some presubmit issues. These changes address the problem by providing some default styles that will be applied if the expansion panel is inside an animating element.
1 parent dcde115 commit 8df25c9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
}
3131
}
3232
}
33+
34+
// If the panel, that the header is in, is inside an element being animated by Angular,
35+
// the default behavior is to block all child animations. This means that the header's
36+
// height won't kick in until the parent animation is done. We add a fallback to the
37+
// header's default height. If the animations aren't blocked, these styles will be overridden
38+
// by the inline styles from the animations module.
39+
.ng-animating .mat-expansion-panel & {
40+
min-height: 48px;
41+
}
42+
43+
.ng-animating .mat-expansion-panel.mat-expanded & {
44+
min-height: 64px;
45+
}
3346
}
3447

3548
.mat-content {

src/material/expansion/expansion-panel.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@
4444
display: flex;
4545
flex-direction: column;
4646
overflow: visible;
47+
48+
// If the expansion panel is inside an element being animated by Angular,
49+
// the default behavior is to block all child animations. This means that the
50+
// default `height: 0` won't kick in until the parent animation is over, which
51+
// will cause the panel to appear open, before it snaps into place. We don't want
52+
// to set the default height to zero, because it'll break the `height: '*'` from
53+
// the animation definitions. Instead we add a fallback that only applies only if
54+
// it's inside a parent that is mid-animation.
55+
.ng-animating .mat-expansion-panel:not(.mat-expanded) & {
56+
height: 0;
57+
overflow: hidden;
58+
}
4759
}
4860

4961
.mat-expansion-panel-body {

0 commit comments

Comments
 (0)