Skip to content

Commit 1d54680

Browse files
crisbetommalerba
authored andcommitted
refactor(dialog): remove deprecated APIs for 9.0.0 (#17333)
Removes the APIs that were scheduled to be removed from the dialog package in v9. BREAKING CHANGES: * `MatDialogRef.afterOpen` has been replaced with `MatDialogRef.afterOpened`. * `MatDialogRef.beforeClose` has been replaced with `MatDialogRef.beforeClosed`. * `MatDialog.afterOpen` has been replaced with `MatDialog.afterOpened`. * `matDialogAnimations.slideDialog` has been replaced with `matDialogAnimations.dialogContainer`. * `_location` parameter in `MatDialogRef` constructor has been removed.
1 parent 3de0b08 commit 1d54680

File tree

7 files changed

+50
-59
lines changed

7 files changed

+50
-59
lines changed

src/material/dialog/dialog-animations.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,23 @@ import {
1414
AnimationTriggerMetadata,
1515
} from '@angular/animations';
1616

17-
const animationBody = [
18-
// Note: The `enter` animation transitions to `transform: none`, because for some reason
19-
// specifying the transform explicitly, causes IE both to blur the dialog content and
20-
// decimate the animation performance. Leaving it as `none` solves both issues.
21-
state('void, exit', style({opacity: 0, transform: 'scale(0.7)'})),
22-
state('enter', style({transform: 'none'})),
23-
transition('* => enter', animate('150ms cubic-bezier(0, 0, 0.2, 1)',
24-
style({transform: 'none', opacity: 1}))),
25-
transition('* => void, * => exit',
26-
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0}))),
27-
];
28-
2917
/**
3018
* Animations used by MatDialog.
3119
* @docs-private
3220
*/
3321
export const matDialogAnimations: {
3422
readonly dialogContainer: AnimationTriggerMetadata;
35-
readonly slideDialog: AnimationTriggerMetadata;
3623
} = {
3724
/** Animation that is applied on the dialog container by defalt. */
38-
dialogContainer: trigger('dialogContainer', animationBody),
39-
40-
/** @deprecated @breaking-change 8.0.0 Use `matDialogAnimations.dialogContainer` instead. */
41-
slideDialog: trigger('slideDialog', animationBody)
25+
dialogContainer: trigger('dialogContainer', [
26+
// Note: The `enter` animation transitions to `transform: none`, because for some reason
27+
// specifying the transform explicitly, causes IE both to blur the dialog content and
28+
// decimate the animation performance. Leaving it as `none` solves both issues.
29+
state('void, exit', style({opacity: 0, transform: 'scale(0.7)'})),
30+
state('enter', style({transform: 'none'})),
31+
transition('* => enter', animate('150ms cubic-bezier(0, 0, 0.2, 1)',
32+
style({transform: 'none', opacity: 1}))),
33+
transition('* => void, * => exit',
34+
animate('75ms cubic-bezier(0.4, 0.0, 0.2, 1)', style({opacity: 0}))),
35+
])
4236
};

src/material/dialog/dialog-ref.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import {ESCAPE, hasModifierKey} from '@angular/cdk/keycodes';
1010
import {GlobalPositionStrategy, OverlayRef} from '@angular/cdk/overlay';
11-
import {Location} from '@angular/common';
1211
import {Observable, Subject} from 'rxjs';
1312
import {filter, take} from 'rxjs/operators';
1413
import {DialogPosition} from './dialog-config';
@@ -54,8 +53,6 @@ export class MatDialogRef<T, R = any> {
5453
constructor(
5554
private _overlayRef: OverlayRef,
5655
public _containerInstance: MatDialogContainer,
57-
// @breaking-change 8.0.0 `_location` parameter to be removed.
58-
_location?: Location,
5956
readonly id: string = `mat-dialog-${uniqueId++}`) {
6057

6158
// Pass the id along to the container.
@@ -213,24 +210,6 @@ export class MatDialogRef<T, R = any> {
213210
return this;
214211
}
215212

216-
/**
217-
* Gets an observable that is notified when the dialog is finished opening.
218-
* @deprecated Use `afterOpened` instead.
219-
* @breaking-change 8.0.0
220-
*/
221-
afterOpen(): Observable<void> {
222-
return this.afterOpened();
223-
}
224-
225-
/**
226-
* Gets an observable that is notified when the dialog has started closing.
227-
* @deprecated Use `beforeClosed` instead.
228-
* @breaking-change 8.0.0
229-
*/
230-
beforeClose(): Observable<R | undefined> {
231-
return this.beforeClosed();
232-
}
233-
234213
/** Gets the current state of the dialog's lifecycle. */
235214
getState(): MatDialogState {
236215
return this._state;

src/material/dialog/dialog.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,23 @@ describe('MatDialog', () => {
207207
expect(overlayContainerElement.querySelector('mat-dialog-container')).toBeNull();
208208
}));
209209

210-
it('should dispatch the beforeClose and afterClose events when the ' +
210+
it('should dispatch the beforeClosed and afterClosed events when the ' +
211211
'overlay is detached externally', fakeAsync(inject([Overlay], (overlay: Overlay) => {
212212
const dialogRef = dialog.open(PizzaMsg, {
213213
viewContainerRef: testViewContainerRef,
214214
scrollStrategy: overlay.scrollStrategies.close()
215215
});
216-
const beforeCloseCallback = jasmine.createSpy('beforeClosed callback');
216+
const beforeClosedCallback = jasmine.createSpy('beforeClosed callback');
217217
const afterCloseCallback = jasmine.createSpy('afterClosed callback');
218218

219-
dialogRef.beforeClose().subscribe(beforeCloseCallback);
219+
dialogRef.beforeClosed().subscribe(beforeClosedCallback);
220220
dialogRef.afterClosed().subscribe(afterCloseCallback);
221221

222222
scrolledSubject.next();
223223
viewContainerFixture.detectChanges();
224224
flush();
225225

226-
expect(beforeCloseCallback).toHaveBeenCalledTimes(1);
226+
expect(beforeClosedCallback).toHaveBeenCalledTimes(1);
227227
expect(afterCloseCallback).toHaveBeenCalledTimes(1);
228228
})));
229229

src/material/dialog/dialog.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ export class MatDialog implements OnDestroy {
8484
return this._parentDialog ? this._parentDialog.afterOpened : this._afterOpenedAtThisLevel;
8585
}
8686

87-
/**
88-
* Stream that emits when a dialog has been opened.
89-
* @deprecated Use `afterOpened` instead.
90-
* @breaking-change 8.0.0
91-
*/
92-
get afterOpen(): Subject<MatDialogRef<any>> {
93-
return this.afterOpened;
94-
}
95-
9687
get _afterAllClosed(): Subject<void> {
9788
const parent = this._parentDialog;
9889
return parent ? parent._afterAllClosed : this._afterAllClosedAtThisLevel;
@@ -110,7 +101,11 @@ export class MatDialog implements OnDestroy {
110101
constructor(
111102
private _overlay: Overlay,
112103
private _injector: Injector,
113-
@Optional() private _location: Location,
104+
/**
105+
* @deprecated `_location` parameter to be removed.
106+
* @breaking-change 10.0.0
107+
*/
108+
@Optional() _location: Location,
114109
@Optional() @Inject(MAT_DIALOG_DEFAULT_OPTIONS) private _defaultOptions: MatDialogConfig,
115110
@Inject(MAT_DIALOG_SCROLL_STRATEGY) scrollStrategy: any,
116111
@Optional() @SkipSelf() private _parentDialog: MatDialog,
@@ -248,7 +243,7 @@ export class MatDialog implements OnDestroy {
248243
// Create a reference to the dialog we're creating in order to give the user a handle
249244
// to modify and close it.
250245
const dialogRef =
251-
new MatDialogRef<T, R>(overlayRef, dialogContainer, this._location, config.id);
246+
new MatDialogRef<T, R>(overlayRef, dialogContainer, config.id);
252247

253248
// When the dialog backdrop is clicked, we want to close it.
254249
if (config.hasBackdrop) {

src/material/schematics/ng-update/data/constructor-checks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
1818
{
1919
pr: 'https://github.com/angular/components/pull/17230',
2020
changes: ['MatSelect']
21+
},
22+
{
23+
pr: 'https://github.com/angular/components/pull/17333',
24+
changes: ['MatDialogRef']
2125
}
2226
],
2327
[TargetVersion.V8]: [

src/material/schematics/ng-update/data/property-names.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99
import {PropertyNameUpgradeData, TargetVersion, VersionChanges} from '@angular/cdk/schematics';
1010

1111
export const propertyNames: VersionChanges<PropertyNameUpgradeData> = {
12+
[TargetVersion.V9]: [
13+
{
14+
pr: 'https://github.com/angular/components/pull/17333',
15+
changes: [
16+
{
17+
replace: 'afterOpen',
18+
replaceWith: 'afterOpened',
19+
whitelist: {classes: ['MatDialogRef']}
20+
},
21+
{
22+
replace: 'beforeClose',
23+
replaceWith: 'beforeClosed',
24+
whitelist: {classes: ['MatDialogRef']}
25+
},
26+
{
27+
replace: 'afterOpen',
28+
replaceWith: 'afterOpened',
29+
whitelist: {classes: ['MatDialog']}
30+
}
31+
]
32+
}
33+
],
1234
[TargetVersion.V6]: [
1335
{
1436
pr: 'https://github.com/angular/components/pull/10163',

tools/public_api_guard/material/dialog.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export declare function MAT_DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay: Ove
2626
export declare class MatDialog implements OnDestroy {
2727
readonly _afterAllClosed: Subject<void>;
2828
readonly afterAllClosed: Observable<void>;
29-
readonly afterOpen: Subject<MatDialogRef<any>>;
3029
readonly afterOpened: Subject<MatDialogRef<any>>;
3130
readonly openDialogs: MatDialogRef<any>[];
32-
constructor(_overlay: Overlay, _injector: Injector, _location: Location, _defaultOptions: MatDialogConfig, scrollStrategy: any, _parentDialog: MatDialog, _overlayContainer: OverlayContainer);
31+
constructor(_overlay: Overlay, _injector: Injector,
32+
_location: Location, _defaultOptions: MatDialogConfig, scrollStrategy: any, _parentDialog: MatDialog, _overlayContainer: OverlayContainer);
3333
closeAll(): void;
3434
getDialogById(id: string): MatDialogRef<any> | undefined;
3535
ngOnDestroy(): void;
@@ -41,7 +41,6 @@ export declare class MatDialogActions {
4141

4242
export declare const matDialogAnimations: {
4343
readonly dialogContainer: AnimationTriggerMetadata;
44-
readonly slideDialog: AnimationTriggerMetadata;
4544
};
4645

4746
export declare class MatDialogClose implements OnInit, OnChanges {
@@ -109,13 +108,11 @@ export declare class MatDialogRef<T, R = any> {
109108
componentInstance: T;
110109
disableClose: boolean | undefined;
111110
readonly id: string;
112-
constructor(_overlayRef: OverlayRef, _containerInstance: MatDialogContainer, _location?: Location, id?: string);
111+
constructor(_overlayRef: OverlayRef, _containerInstance: MatDialogContainer, id?: string);
113112
addPanelClass(classes: string | string[]): this;
114113
afterClosed(): Observable<R | undefined>;
115-
afterOpen(): Observable<void>;
116114
afterOpened(): Observable<void>;
117115
backdropClick(): Observable<MouseEvent>;
118-
beforeClose(): Observable<R | undefined>;
119116
beforeClosed(): Observable<R | undefined>;
120117
close(dialogResult?: R): void;
121118
getState(): MatDialogState;

0 commit comments

Comments
 (0)