Skip to content

Commit 5edcc68

Browse files
authored
fix(multiple): don't block child component animations on open (#24529)
Reworks several components that usually contain projected content not to block animations within that content. This prevents things like expansion panels from appearing as open. These changes are identical to #13888 which had to be reverted in the past. Fixes #13870.
1 parent 2aaa9d4 commit 5edcc68

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

src/cdk-experimental/dialog/dialog-container.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {animate, AnimationEvent, state, style, transition, trigger} from '@angular/animations';
9+
import {
10+
animate,
11+
animateChild,
12+
AnimationEvent,
13+
group,
14+
query,
15+
state,
16+
style,
17+
transition,
18+
trigger,
19+
} from '@angular/animations';
1020
import {FocusTrapFactory, InteractivityChecker} from '@angular/cdk/a11y';
1121
import {_getFocusedElementPierceShadowDom} from '@angular/cdk/platform';
1222
import {
@@ -55,8 +65,20 @@ export function throwDialogContentAlreadyAttachedError() {
5565
trigger('dialog', [
5666
state('enter', style({opacity: 1})),
5767
state('exit, void', style({opacity: 0})),
58-
transition('* => enter', animate('{{enterAnimationDuration}}')),
59-
transition('* => exit, * => void', animate('{{exitAnimationDuration}}')),
68+
transition(
69+
'* => enter',
70+
group([
71+
animate('{{enterAnimationDuration}}'),
72+
query('@*', animateChild(), {optional: true}),
73+
]),
74+
),
75+
transition(
76+
'* => exit, * => void',
77+
group([
78+
animate('{{exitAnimationDuration}}'),
79+
query('@*', animateChild(), {optional: true}),
80+
]),
81+
),
6082
]),
6183
],
6284
host: {

src/material/bottom-sheet/bottom-sheet-animations.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {
1212
transition,
1313
trigger,
1414
AnimationTriggerMetadata,
15+
group,
16+
query,
17+
animateChild,
1518
} from '@angular/animations';
1619
import {AnimationCurves, AnimationDurations} from '@angular/material/core';
1720

@@ -25,11 +28,17 @@ export const matBottomSheetAnimations: {
2528
state('visible', style({transform: 'translateY(0%)'})),
2629
transition(
2730
'visible => void, visible => hidden',
28-
animate(`${AnimationDurations.COMPLEX} ${AnimationCurves.ACCELERATION_CURVE}`),
31+
group([
32+
animate(`${AnimationDurations.COMPLEX} ${AnimationCurves.ACCELERATION_CURVE}`),
33+
query('@*', animateChild(), {optional: true}),
34+
]),
2935
),
3036
transition(
3137
'void => visible',
32-
animate(`${AnimationDurations.EXITING} ${AnimationCurves.DECELERATION_CURVE}`),
38+
group([
39+
animate(`${AnimationDurations.EXITING} ${AnimationCurves.DECELERATION_CURVE}`),
40+
query('@*', animateChild(), {optional: true}),
41+
]),
3342
),
3443
]),
3544
};

src/material/dialog/dialog-animations.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {
1212
transition,
1313
trigger,
1414
AnimationTriggerMetadata,
15+
query,
16+
animateChild,
17+
group,
1518
} from '@angular/animations';
1619

1720
/**
@@ -30,11 +33,17 @@ export const matDialogAnimations: {
3033
state('enter', style({transform: 'none'})),
3134
transition(
3235
'* => enter',
33-
animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({transform: 'none', opacity: 1})),
36+
group([
37+
animate('150ms cubic-bezier(0, 0, 0.2, 1)', style({transform: 'none', opacity: 1})),
38+
query('@*', animateChild(), {optional: true}),
39+
]),
3440
),
3541
transition(
3642
'* => void, * => exit',
37-
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0})),
43+
group([
44+
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0})),
45+
query('@*', animateChild(), {optional: true}),
46+
]),
3847
),
3948
]),
4049
};

0 commit comments

Comments
 (0)