Skip to content

fix(expansion-panel): appearing as open if placed inside animating element #14127

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

Closed
Closed
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
13 changes: 13 additions & 0 deletions src/material/expansion/expansion-panel-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
}
}
}

// If the panel, that the header is in, is inside an element being animated by Angular,
// the default behavior is to block all child animations. This means that the header's
// height won't kick in until the parent animation is done. We add a fallback to the
// header's default height. If the animations aren't blocked, these styles will be overridden
// by the inline styles from the animations module.
.ng-animating .mat-expansion-panel & {
min-height: 48px;
}

.ng-animating .mat-expansion-panel.mat-expanded & {
min-height: 64px;
}
}

.mat-content {
Expand Down
12 changes: 12 additions & 0 deletions src/material/expansion/expansion-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
display: flex;
flex-direction: column;
overflow: visible;

// If the expansion panel is inside an element being animated by Angular,
// the default behavior is to block all child animations. This means that the
// default `height: 0` won't kick in until the parent animation is over, which
// will cause the panel to appear open, before it snaps into place. We don't want
// to set the default height to zero, because it'll break the `height: '*'` from
// the animation definitions. Instead we add a fallback that only applies only if
// it's inside a parent that is mid-animation.
.ng-animating .mat-expansion-panel:not(.mat-expanded) & {
height: 0;
overflow: hidden;
}
}

.mat-expansion-panel-body {
Expand Down