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 Vivian Hu committed Nov 6, 2018
1 parent 6c741c4 commit fdfdcd5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/expansion/expansion-animations.ts
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 fdfdcd5

Please sign in to comment.