Skip to content

Commit 542e6c2

Browse files
committed
fix(material/expansion): all panels appearing open when printing
Fixes that closed expansion panel were appearing as open when printing the page. Fixes #32327.
1 parent ef53e73 commit 542e6c2

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/material/expansion/expansion-panel.scss

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
@use '@angular/cdk';
32
@use './m3-expansion';
43
@use '../core/tokens/token-utils';
@@ -14,8 +13,9 @@ $fallbacks: m3-expansion.get-tokens();
1413
overflow: hidden;
1514

1615
&.mat-expansion-panel-animations-enabled {
17-
transition: margin 225ms variables.$fast-out-slow-in-timing-function,
18-
elevation.private-transition-property-value();
16+
transition:
17+
margin 225ms variables.$fast-out-slow-in-timing-function,
18+
elevation.private-transition-property-value();
1919
}
2020

2121
// Required so that the `box-shadow` works after the
@@ -31,7 +31,8 @@ $fallbacks: m3-expansion.get-tokens();
3131
}
3232

3333
.mat-accordion & {
34-
&:not(.mat-expanded), &:not(.mat-expansion-panel-spacing) {
34+
&:not(.mat-expanded),
35+
&:not(.mat-expansion-panel-spacing) {
3536
border-radius: 0;
3637
}
3738

@@ -51,6 +52,15 @@ $fallbacks: m3-expansion.get-tokens();
5152
}
5253
}
5354

55+
// Styles to use if grid isn't supported for some reason.
56+
@mixin _fallback-styles {
57+
height: 0;
58+
59+
.mat-expansion-panel.mat-expanded > & {
60+
height: auto;
61+
}
62+
}
63+
5464
.mat-expansion-panel-content-wrapper {
5565
// Note: we can't use `overflow: hidden` here, because it can clip content with
5666
// ripples or box shadows. Instead we transition the `visibility` below.
@@ -72,13 +82,14 @@ $fallbacks: m3-expansion.get-tokens();
7282
// we have a fallback to `height` which doesn't animate, just in case.
7383
// stylelint-disable material/no-prefixes
7484
@supports not (grid-template-rows: 0fr) {
75-
height: 0;
76-
77-
.mat-expansion-panel.mat-expanded > & {
78-
height: auto;
79-
}
85+
@include _fallback-styles;
8086
}
8187
// stylelint-enable material/no-prefixes
88+
89+
// Use the fallback styles when printing, otherwise closed panel appear open (see #32327).
90+
@media print {
91+
@include _fallback-styles;
92+
}
8293
}
8394

8495
.mat-expansion-panel-content {
@@ -137,7 +148,8 @@ $fallbacks: m3-expansion.get-tokens();
137148

138149
border-top-color: token-utils.slot(expansion-actions-divider-color, $fallbacks);
139150

140-
.mat-button-base, .mat-mdc-button-base {
151+
.mat-button-base,
152+
.mat-mdc-button-base {
141153
margin-left: 8px;
142154

143155
[dir='rtl'] & {

0 commit comments

Comments
 (0)