Skip to content

Commit

Permalink
fix(material/stepper): allow child animations to run (angular#27338)
Browse files Browse the repository at this point in the history
Currently the stepper doesn't explicitly allow child animations to run which means that other componets like expansion panels may be blocked from animating their initial state.

These changes add an `animateChild` query to the stepper to unblock the child animations.

Fixes angular#27318.
  • Loading branch information
crisbeto authored Jun 21, 2023
1 parent 6d0d47e commit 53242fe
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/material/stepper/stepper-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
transition,
trigger,
AnimationTriggerMetadata,
group,
query,
animateChild,
} from '@angular/animations';

export const DEFAULT_HORIZONTAL_ANIMATION_DURATION = '500ms';
Expand All @@ -33,9 +36,16 @@ export const matStepperAnimations: {
// making this element focusable inside of a `hidden` element.
state('current', style({transform: 'none', visibility: 'inherit'})),
state('next', style({transform: 'translate3d(100%, 0, 0)', visibility: 'hidden'})),
transition('* => *', animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)'), {
params: {'animationDuration': DEFAULT_HORIZONTAL_ANIMATION_DURATION},
}),
transition(
'* => *',
group([
animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)'),
query('@*', animateChild(), {optional: true}),
]),
{
params: {'animationDuration': DEFAULT_HORIZONTAL_ANIMATION_DURATION},
},
),
]),

/** Animation that transitions the step along the Y axis in a vertical stepper. */
Expand All @@ -46,8 +56,15 @@ export const matStepperAnimations: {
// because visibility on a child element the one from the parent,
// making this element focusable inside of a `hidden` element.
state('current', style({height: '*', visibility: 'inherit'})),
transition('* <=> current', animate('{{animationDuration}} cubic-bezier(0.4, 0.0, 0.2, 1)'), {
params: {'animationDuration': DEFAULT_VERTICAL_ANIMATION_DURATION},
}),
transition(
'* <=> current',
group([
animate('{{animationDuration}} cubic-bezier(0.4, 0.0, 0.2, 1)'),
query('@*', animateChild(), {optional: true}),
]),
{
params: {'animationDuration': DEFAULT_VERTICAL_ANIMATION_DURATION},
},
),
]),
};

0 comments on commit 53242fe

Please sign in to comment.