Skip to content

Commit 16fe90e

Browse files
committed
fix(material/expansion): panel appearing as open when parent is animating away
Fixes an issue where the expansion panel will appear as if it is open, if the element is part of a component that is animating away. The issue comes from the fact that Angular resets the animation state to `void` which we don't have in the animation definitions. Fixes #11765.
1 parent ade0901 commit 16fe90e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/material/expansion/expansion-animations.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ export const matExpansionAnimations: {
5353
]),
5454
/** Animation that expands and collapses the panel content. */
5555
bodyExpansion: trigger('bodyExpansion', [
56+
// Note: we also have `void` here as a fallback, because Angular will reset the
57+
// state back to void when the element is being removed. See #11765.
5658
state('collapsed, void', style({height: '0px', visibility: 'hidden'})),
5759
state('expanded', style({height: '*', visibility: 'visible'})),
58-
transition('expanded <=> collapsed, void => collapsed',
59-
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
60+
transition('expanded <=> collapsed, expanded <=> void, void => collapsed',
61+
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
6062
])
6163
};

0 commit comments

Comments
 (0)