Skip to content

Commit fdfdcd5

Browse files
crisbetoVivian Hu
authored and
Vivian Hu
committed
fix(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 6c741c4 commit fdfdcd5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lib/expansion/expansion-animations.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@ export const matExpansionAnimations: {
6767
}), {
6868
params: {expandedHeight: '64px'}
6969
}),
70-
transition('expanded <=> collapsed, void => collapsed', group([
70+
transition('expanded <=> collapsed, expanded <=> void, void => collapsed', group([
7171
query('@indicatorRotate', animateChild(), {optional: true}),
7272
animate(EXPANSION_PANEL_ANIMATION_TIMING),
7373
])),
7474
]),
7575

7676
/** Animation that expands and collapses the panel content. */
7777
bodyExpansion: trigger('bodyExpansion', [
78+
// Note: we also have `void` here as a fallback, because Angular will reset the
79+
// state back to void when the element is being removed. See #11765.
7880
state('collapsed, void', style({height: '0px', visibility: 'hidden'})),
7981
state('expanded', style({height: '*', visibility: 'visible'})),
80-
transition('expanded <=> collapsed, void => collapsed',
81-
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
82+
transition('expanded <=> collapsed, expanded <=> void, void => collapsed',
83+
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
8284
])
8385
};

0 commit comments

Comments
 (0)