From 8c3d791562e28902aded5c4e73b2337b74452ebc Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Sun, 25 Sep 2022 10:50:16 +0200 Subject: [PATCH] fix(material/bottom-sheet): aria-modal not being set Fixes that `aria-modal` wasn't being set on the bottom sheet container. This likely broke when the bottom sheet was refactored to use the CDK dialog. (cherry picked from commit 90e6446348f466554874a788d6747600990e9948) --- src/material/bottom-sheet/bottom-sheet-config.ts | 3 +++ src/material/bottom-sheet/bottom-sheet-container.ts | 2 +- src/material/bottom-sheet/bottom-sheet.spec.ts | 1 + tools/public_api_guard/material/bottom-sheet.md | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/material/bottom-sheet/bottom-sheet-config.ts b/src/material/bottom-sheet/bottom-sheet-config.ts index 3fe197d44461..568a5a889e2d 100644 --- a/src/material/bottom-sheet/bottom-sheet-config.ts +++ b/src/material/bottom-sheet/bottom-sheet-config.ts @@ -44,6 +44,9 @@ export class MatBottomSheetConfig { /** Aria label to assign to the bottom sheet element. */ ariaLabel?: string | null = null; + /** Whether this is a modal bottom sheet. Used to set the `aria-modal` attribute. */ + ariaModal?: boolean = true; + /** * Whether the bottom sheet should close when the user goes backwards/forwards in history. * Note that this usually doesn't include clicking on links (unless the user is using diff --git a/src/material/bottom-sheet/bottom-sheet-container.ts b/src/material/bottom-sheet/bottom-sheet-container.ts index 16d31898f348..1a2b87a94f7a 100644 --- a/src/material/bottom-sheet/bottom-sheet-container.ts +++ b/src/material/bottom-sheet/bottom-sheet-container.ts @@ -47,7 +47,7 @@ import {matBottomSheetAnimations} from './bottom-sheet-animations'; 'class': 'mat-bottom-sheet-container', 'tabindex': '-1', '[attr.role]': '_config.role', - '[attr.aria-modal]': '_config.isModal', + '[attr.aria-modal]': '_config.ariaModal', '[attr.aria-label]': '_config.ariaLabel', '[@state]': '_animationState', '(@state.start)': '_onAnimationStart($event)', diff --git a/src/material/bottom-sheet/bottom-sheet.spec.ts b/src/material/bottom-sheet/bottom-sheet.spec.ts index ee4a01362b48..e25ff7cb5a0d 100644 --- a/src/material/bottom-sheet/bottom-sheet.spec.ts +++ b/src/material/bottom-sheet/bottom-sheet.spec.ts @@ -156,6 +156,7 @@ describe('MatBottomSheet', () => { const containerElement = overlayContainerElement.querySelector('mat-bottom-sheet-container')!; expect(containerElement.getAttribute('role')).toBe('dialog'); + expect(containerElement.getAttribute('aria-modal')).toBe('true'); }); it('should close a bottom sheet via the escape key', fakeAsync(() => { diff --git a/tools/public_api_guard/material/bottom-sheet.md b/tools/public_api_guard/material/bottom-sheet.md index e54e21a37c13..c24e4c8ffe83 100644 --- a/tools/public_api_guard/material/bottom-sheet.md +++ b/tools/public_api_guard/material/bottom-sheet.md @@ -66,6 +66,7 @@ export const matBottomSheetAnimations: { // @public export class MatBottomSheetConfig { ariaLabel?: string | null; + ariaModal?: boolean; autoFocus?: AutoFocusTarget | string | boolean; backdropClass?: string; closeOnNavigation?: boolean;