Skip to content

Commit

Permalink
fix(material/bottom-sheet): aria-modal not being set
Browse files Browse the repository at this point in the history
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 90e6446)
  • Loading branch information
crisbeto committed Sep 26, 2022
1 parent 7d314a8 commit 8c3d791
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/material/bottom-sheet/bottom-sheet-config.ts
Expand Up @@ -44,6 +44,9 @@ export class MatBottomSheetConfig<D = any> {
/** 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
Expand Down
2 changes: 1 addition & 1 deletion src/material/bottom-sheet/bottom-sheet-container.ts
Expand Up @@ -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)',
Expand Down
1 change: 1 addition & 0 deletions src/material/bottom-sheet/bottom-sheet.spec.ts
Expand Up @@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions tools/public_api_guard/material/bottom-sheet.md
Expand Up @@ -66,6 +66,7 @@ export const matBottomSheetAnimations: {
// @public
export class MatBottomSheetConfig<D = any> {
ariaLabel?: string | null;
ariaModal?: boolean;
autoFocus?: AutoFocusTarget | string | boolean;
backdropClass?: string;
closeOnNavigation?: boolean;
Expand Down

0 comments on commit 8c3d791

Please sign in to comment.