Skip to content

Commit 1597b08

Browse files
crisbetoandrewseguin
authored andcommitted
fix(experimental/dialog): set aria-modal on dialog container (#16323)
Fixes the experimental dialog container not having `aria-modal`.
1 parent 862f4cd commit 1597b08

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class CdkDialogContainer extends BasePortalOutlet implements OnDestroy {
8282
/** The class that traps and manages focus within the dialog. */
8383
private _focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement, false);
8484

85-
// @HostBinding is used in the class as it is expected to be extended. Since @Component decorator
85+
// @HostBinding is used in the class as it is expected to be extended. Since @Component decorator
8686
// metadata is not inherited by child classes, instead the host binding data is defined in a way
8787
// that can be inherited.
8888
// tslint:disable:no-host-decorator-in-concrete
@@ -93,6 +93,8 @@ export class CdkDialogContainer extends BasePortalOutlet implements OnDestroy {
9393

9494
@HostBinding('attr.role') get _role() { return this._config.role; }
9595

96+
@HostBinding('attr.aria-modal') _ariaModal = true;
97+
9698
@HostBinding('attr.tabindex') get _tabindex() { return -1; }
9799
// tslint:disable:no-host-decorator-in-concrete
98100

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ describe('Dialog', () => {
7979
viewContainerFixture.detectChanges();
8080
let dialogContainerElement = overlayContainerElement.querySelector('cdk-dialog-container')!;
8181
expect(dialogContainerElement.getAttribute('role')).toBe('dialog');
82+
expect(dialogContainerElement.getAttribute('aria-modal')).toBe('true');
8283
});
8384

8485
it('should open a dialog with a template', () => {
@@ -100,6 +101,7 @@ describe('Dialog', () => {
100101

101102
let dialogContainerElement = overlayContainerElement.querySelector('cdk-dialog-container')!;
102103
expect(dialogContainerElement.getAttribute('role')).toBe('dialog');
104+
expect(dialogContainerElement.getAttribute('aria-modal')).toBe('true');
103105

104106
dialogRef.close();
105107
});

0 commit comments

Comments
 (0)