Skip to content

Commit f165484

Browse files
authored
fix(material/dialog): provide defaults for dialog animation (#24591)
Even though we provide defaults when we construct the animation object, some internal cases break because there are no defaults in the animation definition itself. These changes provide the defaults in the animation definition as well.
1 parent 6b4f2bf commit f165484

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/material/dialog/dialog-animations.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ import {
1717
group,
1818
} from '@angular/animations';
1919

20+
/**
21+
* Default parameters for the animation for backwards compatibility.
22+
* @docs-private
23+
*/
24+
export const defaultParams = {
25+
params: {enterAnimationDuration: '150ms', exitAnimationDuration: '75ms'},
26+
};
27+
2028
/**
2129
* Animations used by MatDialog.
2230
* @docs-private
@@ -40,13 +48,15 @@ export const matDialogAnimations: {
4048
),
4149
query('@*', animateChild(), {optional: true}),
4250
]),
51+
defaultParams,
4352
),
4453
transition(
4554
'* => void, * => exit',
4655
group([
4756
animate('{{exitAnimationDuration}} cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0})),
4857
query('@*', animateChild(), {optional: true}),
4958
]),
59+
defaultParams,
5060
),
5161
]),
5262
};

src/material/dialog/dialog-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import {ViewContainerRef, ComponentFactoryResolver} from '@angular/core';
1010
import {Direction} from '@angular/cdk/bidi';
1111
import {ScrollStrategy} from '@angular/cdk/overlay';
12+
import {defaultParams} from './dialog-animations';
1213

1314
/** Options for where to set focus to automatically on dialog open */
1415
export type AutoFocusTarget = 'dialog' | 'first-tabbable' | 'first-heading';
@@ -127,10 +128,10 @@ export class MatDialogConfig<D = any> {
127128
componentFactoryResolver?: ComponentFactoryResolver;
128129

129130
/** Duration of the enter animation. Has to be a valid CSS value (e.g. 100ms). */
130-
enterAnimationDuration?: string = '150ms';
131+
enterAnimationDuration?: string = defaultParams.params.enterAnimationDuration;
131132

132133
/** Duration of the exit animation. Has to be a valid CSS value (e.g. 50ms). */
133-
exitAnimationDuration?: string = '75ms';
134+
exitAnimationDuration?: string = defaultParams.params.exitAnimationDuration;
134135

135136
// TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
136137
}

src/material/dialog/dialog-container.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
ViewChild,
3939
ViewEncapsulation,
4040
} from '@angular/core';
41-
import {matDialogAnimations} from './dialog-animations';
41+
import {matDialogAnimations, defaultParams} from './dialog-animations';
4242
import {MatDialogConfig} from './dialog-config';
4343

4444
/** Event that captures the state of dialog container animations. */
@@ -365,8 +365,10 @@ export class MatDialogContainer extends _MatDialogContainerBase {
365365
return {
366366
value: this._state,
367367
params: {
368-
enterAnimationDuration: this._config.enterAnimationDuration || '150ms',
369-
exitAnimationDuration: this._config.exitAnimationDuration || '75ms',
368+
enterAnimationDuration:
369+
this._config.enterAnimationDuration || defaultParams.params.enterAnimationDuration,
370+
exitAnimationDuration:
371+
this._config.exitAnimationDuration || defaultParams.params.exitAnimationDuration,
370372
},
371373
};
372374
}

src/material/dialog/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export * from './dialog-container';
1212
export * from './dialog-content-directives';
1313
export * from './dialog-config';
1414
export * from './dialog-ref';
15-
export * from './dialog-animations';
15+
export {matDialogAnimations} from './dialog-animations';

0 commit comments

Comments
 (0)