Skip to content

Commit

Permalink
fix(expansion): panel appearing as open when parent is animating away
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored and mmalerba committed Apr 7, 2020
1 parent 8a71288 commit edfbefd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/material/expansion/expansion-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ export const matExpansionAnimations: {
}), {
params: {expandedHeight: '64px'}
}),
transition('expanded <=> collapsed, void => collapsed', group([
transition('expanded <=> collapsed, expanded <=> void, void => collapsed', group([
query('@indicatorRotate', animateChild(), {optional: true}),
animate(EXPANSION_PANEL_ANIMATION_TIMING),
])),
]),

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

0 comments on commit edfbefd

Please sign in to comment.