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 angular#11765.
  • Loading branch information
crisbeto committed Jan 1, 2020
1 parent 09dc459 commit 639b3c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/material/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 639b3c2

Please sign in to comment.