Skip to content

Commit 439852b

Browse files
authored
feat(material/dialog): Switch dialog implementation to use MDC (#25352)
* feat(material/dialog): Switch dialog implementation to use MDC Old implementation is still available under @angular/material/legacy-dialog BREAKING CHANGE: - DOM and CSS classes for mat-dialog have changes - Typescript API is largely the same but may have minor differences - See the MDC migration guide for more information about the changes and how to migrate your app (TODO: link when available) * fixup! feat(material/dialog): Switch dialog implementation to use MDC
1 parent 3041cda commit 439852b

File tree

114 files changed

+2113
-1657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+2113
-1657
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/src/material/legacy-checkbox/** @andrewseguin @devversion
1010
/src/material/chips/** @andrewseguin
1111
/src/material/datepicker/** @mmalerba @crisbeto @zarend
12-
/src/material/dialog/** @andrewseguin @crisbeto
12+
/src/material/legacy-dialog/** @andrewseguin @crisbeto
1313
/src/material/divider/** @andrewseguin @crisbeto
1414
/src/material/expansion/** @andrewseguin
1515
/src/material/legacy-form-field/** @mmalerba
@@ -116,7 +116,7 @@
116116
/src/material/checkbox/** @mmalerba
117117
/src/material-experimental/mdc-chips/** @mmalerba
118118
/src/material-experimental/mdc-core/** @crisbeto
119-
/src/material-experimental/mdc-dialog/** @devversion
119+
/src/material/dialog/** @devversion
120120
/src/material/form-field/** @devversion @mmalerba
121121
/src/material-experimental/mdc-list/** @mmalerba @devversion
122122
/src/material-experimental/mdc-menu/** @crisbeto
@@ -326,7 +326,7 @@
326326
/tools/public_api_guard/material/chips/testing** @andrewseguin
327327
/tools/public_api_guard/material/core** @andrewseguin
328328
/tools/public_api_guard/material/datepicker** @mmalerba @crisbeto @zarend
329-
/tools/public_api_guard/material/dialog** @andrewseguin @crisbeto
329+
/tools/public_api_guard/material/legacy-dialog** @andrewseguin @crisbeto
330330
/tools/public_api_guard/material/divider** @andrewseguin @crisbeto
331331
/tools/public_api_guard/material/expansion** @andrewseguin
332332
/tools/public_api_guard/material/form-field** @mmalerba

.ng-dev/commit-message.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const commitMessage: CommitMessageConfig = {
4545
'material/checkbox',
4646
'material-experimental/mdc-chips',
4747
'material-experimental/mdc-core',
48-
'material-experimental/mdc-dialog',
48+
'material/dialog',
4949
'material/form-field',
5050
'material/input',
5151
'material-experimental/mdc-list',
@@ -79,7 +79,7 @@ export const commitMessage: CommitMessageConfig = {
7979
'material/core',
8080
'material/legacy-core',
8181
'material/datepicker',
82-
'material/dialog',
82+
'material/legacy-dialog',
8383
'material/divider',
8484
'material/expansion',
8585
'material/form-field',

CHANGELOG_ARCHIVE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ We expect to have the tool ready when we release version 6.0.0.
16401640
* **menu:** not closing when overlay is detached externally ([#8868](https://github.com/angular/material2/issues/8868)) ([534c797](https://github.com/angular/material2/commit/534c797))
16411641
* **overlay:** export OverlaySizeConfig ([#8932](https://github.com/angular/material2/issues/8932)) ([adfa31e](https://github.com/angular/material2/commit/adfa31e))
16421642
* **paginator:** set default display value ([#8455](https://github.com/angular/material2/issues/8455)) ([ccb325e](https://github.com/angular/material2/commit/ccb325e)), closes [#8454](https://github.com/angular/material2/issues/8454)
1643-
* **portal:** inaccurate hasAttahed result and portal being cleared if attached too early ([#8642](https://github.com/angular/material2/issues/8642)) ([93e6c53](https://github.com/angular/material2/commit/93e6c53)), closes [/github.com/angular/material2/blob/main/src/material/dialog/dialog-container.ts#L118](https://github.com//github.com/angular/material2/blob/main/src/material/dialog/dialog-container.ts/issues/L118) [#8628](https://github.com/angular/material2/issues/8628)
1643+
* **portal:** inaccurate hasAttahed result and portal being cleared if attached too early ([#8642](https://github.com/angular/material2/issues/8642)) ([93e6c53](https://github.com/angular/material2/commit/93e6c53)), closes [/github.com/angular/material2/blob/main/src/material/legacy-dialog/dialog-container.ts#L118](https://github.com//github.com/angular/material2/blob/main/src/material/legacy-dialog/dialog-container.ts/issues/L118) [#8628](https://github.com/angular/material2/issues/8628)
16441644
* **select:** alt + arrow key not opening in single-selection mode ([#8910](https://github.com/angular/material2/issues/8910)) ([85f83f9](https://github.com/angular/material2/commit/85f83f9))
16451645
* **select:** change event emitted before data binding is updated ([#8740](https://github.com/angular/material2/issues/8740)) ([2493797](https://github.com/angular/material2/commit/2493797)), closes [#8739](https://github.com/angular/material2/issues/8739)
16461646
* **select:** complete state change event ([#8777](https://github.com/angular/material2/issues/8777)) ([46411e3](https://github.com/angular/material2/commit/46411e3))
@@ -3889,4 +3889,4 @@ This inaugural release includes 6 components:
38893889
As the alpha process continues, these components will continue to evolve. There *will* be
38903890
breaking changes between alpha releases; the alpha releases are here for people that want an
38913891
early look or who like to live on the edge and are very tolerant of breaking API and behavior
3892-
changes.
3892+
changes.

src/components-examples/material/dialog/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ ng_module(
1616
"//src/cdk/testing",
1717
"//src/cdk/testing/testbed",
1818
"//src/material/button",
19-
"//src/material/dialog",
20-
"//src/material/dialog/testing",
19+
"//src/material/legacy-dialog",
20+
"//src/material/legacy-dialog/testing",
2121
"//src/material/legacy-input",
2222
"//src/material/menu",
2323
"@npm//@angular/forms",
@@ -43,8 +43,8 @@ ng_test_library(
4343
":dialog",
4444
"//src/cdk/testing",
4545
"//src/cdk/testing/testbed",
46-
"//src/material/dialog",
47-
"//src/material/dialog/testing",
46+
"//src/material/legacy-dialog",
47+
"//src/material/legacy-dialog/testing",
4848
"@npm//@angular/platform-browser",
4949
"@npm//@angular/platform-browser-dynamic",
5050
],

src/components-examples/material/dialog/dialog-animations/dialog-animations-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
2+
import {MatLegacyDialog, MatLegacyDialogRef} from '@angular/material/legacy-dialog';
33

44
/**
55
* @title Dialog Animations
@@ -10,7 +10,7 @@ import {MatDialog, MatDialogRef} from '@angular/material/dialog';
1010
templateUrl: 'dialog-animations-example.html',
1111
})
1212
export class DialogAnimationsExample {
13-
constructor(public dialog: MatDialog) {}
13+
constructor(public dialog: MatLegacyDialog) {}
1414

1515
openDialog(enterAnimationDuration: string, exitAnimationDuration: string): void {
1616
this.dialog.open(DialogAnimationsExampleDialog, {
@@ -26,5 +26,5 @@ export class DialogAnimationsExample {
2626
templateUrl: 'dialog-animations-example-dialog.html',
2727
})
2828
export class DialogAnimationsExampleDialog {
29-
constructor(public dialogRef: MatDialogRef<DialogAnimationsExampleDialog>) {}
29+
constructor(public dialogRef: MatLegacyDialogRef<DialogAnimationsExampleDialog>) {}
3030
}

src/components-examples/material/dialog/dialog-content/dialog-content-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MatDialog} from '@angular/material/dialog';
2+
import {MatLegacyDialog} from '@angular/material/legacy-dialog';
33

44
/**
55
* @title Dialog with header, scrollable content and actions
@@ -9,7 +9,7 @@ import {MatDialog} from '@angular/material/dialog';
99
templateUrl: 'dialog-content-example.html',
1010
})
1111
export class DialogContentExample {
12-
constructor(public dialog: MatDialog) {}
12+
constructor(public dialog: MatLegacyDialog) {}
1313

1414
openDialog() {
1515
const dialogRef = this.dialog.open(DialogContentExampleDialog);

src/components-examples/material/dialog/dialog-data/dialog-data-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, Inject} from '@angular/core';
2-
import {MatDialog, MAT_DIALOG_DATA} from '@angular/material/dialog';
2+
import {MatLegacyDialog, MAT_LEGACY_DIALOG_DATA} from '@angular/material/legacy-dialog';
33

44
export interface DialogData {
55
animal: 'panda' | 'unicorn' | 'lion';
@@ -13,7 +13,7 @@ export interface DialogData {
1313
templateUrl: 'dialog-data-example.html',
1414
})
1515
export class DialogDataExample {
16-
constructor(public dialog: MatDialog) {}
16+
constructor(public dialog: MatLegacyDialog) {}
1717

1818
openDialog() {
1919
this.dialog.open(DialogDataExampleDialog, {
@@ -29,5 +29,5 @@ export class DialogDataExample {
2929
templateUrl: 'dialog-data-example-dialog.html',
3030
})
3131
export class DialogDataExampleDialog {
32-
constructor(@Inject(MAT_DIALOG_DATA) public data: DialogData) {}
32+
constructor(@Inject(MAT_LEGACY_DIALOG_DATA) public data: DialogData) {}
3333
}

src/components-examples/material/dialog/dialog-elements/dialog-elements-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {MatDialog} from '@angular/material/dialog';
2+
import {MatLegacyDialog} from '@angular/material/legacy-dialog';
33

44
/**
55
* @title Dialog elements
@@ -9,7 +9,7 @@ import {MatDialog} from '@angular/material/dialog';
99
templateUrl: 'dialog-elements-example.html',
1010
})
1111
export class DialogElementsExample {
12-
constructor(public dialog: MatDialog) {}
12+
constructor(public dialog: MatLegacyDialog) {}
1313

1414
openDialog() {
1515
this.dialog.open(DialogElementsExampleDialog);

src/components-examples/material/dialog/dialog-from-menu/dialog-from-menu-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewChild} from '@angular/core';
2-
import {MatDialog} from '@angular/material/dialog';
2+
import {MatLegacyDialog} from '@angular/material/legacy-dialog';
33
import {MatMenuTrigger} from '@angular/material/menu';
44
/**
55
* @title Dialog launched from a menu
@@ -11,7 +11,7 @@ import {MatMenuTrigger} from '@angular/material/menu';
1111
export class DialogFromMenuExample {
1212
@ViewChild('menuTrigger') menuTrigger: MatMenuTrigger;
1313

14-
constructor(public dialog: MatDialog) {}
14+
constructor(public dialog: MatLegacyDialog) {}
1515

1616
openDialog() {
1717
// #docregion focus-restoration
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
22
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
3-
import {MatDialogHarness} from '@angular/material/dialog/testing';
3+
import {MatLegacyDialogHarness} from '@angular/material/legacy-dialog/testing';
44
import {HarnessLoader} from '@angular/cdk/testing';
5-
import {MatDialogModule} from '@angular/material/dialog';
5+
import {MatLegacyDialogModule} from '@angular/material/legacy-dialog';
66
import {DialogHarnessExample} from './dialog-harness-example';
77
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
88

@@ -12,7 +12,7 @@ describe('DialogHarnessExample', () => {
1212

1313
beforeEach(waitForAsync(async () => {
1414
await TestBed.configureTestingModule({
15-
imports: [MatDialogModule, NoopAnimationsModule],
15+
imports: [MatLegacyDialogModule, NoopAnimationsModule],
1616
declarations: [DialogHarnessExample],
1717
}).compileComponents();
1818
fixture = TestBed.createComponent(DialogHarnessExample);
@@ -22,42 +22,42 @@ describe('DialogHarnessExample', () => {
2222

2323
it('should load harness for dialog', async () => {
2424
fixture.componentInstance.open();
25-
const dialogs = await loader.getAllHarnesses(MatDialogHarness);
25+
const dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness);
2626
expect(dialogs.length).toBe(1);
2727
});
2828

2929
it('should load harness for dialog with specific id', async () => {
3030
fixture.componentInstance.open({id: 'my-dialog'});
3131
fixture.componentInstance.open({id: 'other'});
32-
let dialogs = await loader.getAllHarnesses(MatDialogHarness);
32+
let dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness);
3333
expect(dialogs.length).toBe(2);
3434

35-
dialogs = await loader.getAllHarnesses(MatDialogHarness.with({selector: '#my-dialog'}));
35+
dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness.with({selector: '#my-dialog'}));
3636
expect(dialogs.length).toBe(1);
3737
});
3838

3939
it('should be able to get role of dialog', async () => {
4040
fixture.componentInstance.open({role: 'alertdialog'});
4141
fixture.componentInstance.open({role: 'dialog'});
42-
const dialogs = await loader.getAllHarnesses(MatDialogHarness);
42+
const dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness);
4343
expect(await dialogs[0].getRole()).toBe('alertdialog');
4444
expect(await dialogs[1].getRole()).toBe('dialog');
4545
});
4646

4747
it('should be able to close dialog', async () => {
4848
fixture.componentInstance.open({disableClose: true});
4949
fixture.componentInstance.open();
50-
let dialogs = await loader.getAllHarnesses(MatDialogHarness);
50+
let dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness);
5151

5252
expect(dialogs.length).toBe(2);
5353
await dialogs[0].close();
5454

55-
dialogs = await loader.getAllHarnesses(MatDialogHarness);
55+
dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness);
5656
expect(dialogs.length).toBe(1);
5757

5858
// should be a noop since "disableClose" is set to "true".
5959
await dialogs[0].close();
60-
dialogs = await loader.getAllHarnesses(MatDialogHarness);
60+
dialogs = await loader.getAllHarnesses(MatLegacyDialogHarness);
6161
expect(dialogs.length).toBe(1);
6262
});
6363
});

src/components-examples/material/dialog/dialog-harness/dialog-harness-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, TemplateRef, ViewChild} from '@angular/core';
2-
import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
2+
import {MatLegacyDialog, MatLegacyDialogConfig} from '@angular/material/legacy-dialog';
33

44
/**
55
* @title Testing with MatDialogHarness
@@ -11,9 +11,9 @@ import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
1111
export class DialogHarnessExample {
1212
@ViewChild(TemplateRef) dialogTemplate: TemplateRef<any>;
1313

14-
constructor(readonly dialog: MatDialog) {}
14+
constructor(readonly dialog: MatLegacyDialog) {}
1515

16-
open(config?: MatDialogConfig) {
16+
open(config?: MatLegacyDialogConfig) {
1717
return this.dialog.open(this.dialogTemplate, config);
1818
}
1919
}

src/components-examples/material/dialog/dialog-overview/dialog-overview-example.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {Component, Inject} from '@angular/core';
2-
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
2+
import {
3+
MatLegacyDialog,
4+
MAT_LEGACY_DIALOG_DATA,
5+
MatLegacyDialogRef,
6+
} from '@angular/material/legacy-dialog';
37

48
export interface DialogData {
59
animal: string;
@@ -17,7 +21,7 @@ export class DialogOverviewExample {
1721
animal: string;
1822
name: string;
1923

20-
constructor(public dialog: MatDialog) {}
24+
constructor(public dialog: MatLegacyDialog) {}
2125

2226
openDialog(): void {
2327
const dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
@@ -38,8 +42,8 @@ export class DialogOverviewExample {
3842
})
3943
export class DialogOverviewExampleDialog {
4044
constructor(
41-
public dialogRef: MatDialogRef<DialogOverviewExampleDialog>,
42-
@Inject(MAT_DIALOG_DATA) public data: DialogData,
45+
public dialogRef: MatLegacyDialogRef<DialogOverviewExampleDialog>,
46+
@Inject(MAT_LEGACY_DIALOG_DATA) public data: DialogData,
4347
) {}
4448

4549
onNoClick(): void {

src/components-examples/material/dialog/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {CommonModule} from '@angular/common';
22
import {NgModule} from '@angular/core';
33
import {FormsModule} from '@angular/forms';
44
import {MatButtonModule} from '@angular/material/button';
5-
import {MatDialogModule} from '@angular/material/dialog';
5+
import {MatLegacyDialogModule} from '@angular/material/legacy-dialog';
66
import {MatLegacyInputModule} from '@angular/material/legacy-input';
77
import {MatMenuModule} from '@angular/material/menu';
88
import {
@@ -64,7 +64,7 @@ const EXAMPLES = [
6464
imports: [
6565
CommonModule,
6666
MatButtonModule,
67-
MatDialogModule,
67+
MatLegacyDialogModule,
6868
MatLegacyInputModule,
6969
MatMenuModule,
7070
FormsModule,

src/dev-app/dialog/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ ng_module(
1212
deps = [
1313
"//src/cdk/drag-drop",
1414
"//src/material/button",
15-
"//src/material/dialog",
1615
"//src/material/legacy-card",
1716
"//src/material/legacy-checkbox",
17+
"//src/material/legacy-dialog",
1818
"//src/material/legacy-form-field",
1919
"//src/material/legacy-input",
2020
"//src/material/legacy-select",

0 commit comments

Comments
 (0)