Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dialog): add config option for aria-describedby #5365

Merged
merged 1 commit into from
Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/dialog/dialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@ export class MdDialogConfig {
/** Layout direction for the dialog's content. */
direction?: Direction = 'ltr';

/** ID of the element that describes the dialog. */
ariaDescribedBy?: string | null = null;

// TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
}
1 change: 1 addition & 0 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function throwMdDialogContentAlreadyAttachedError() {
'class': 'mat-dialog-container',
'[attr.role]': '_config?.role',
'[attr.aria-labelledby]': '_ariaLabelledBy',
'[attr.aria-describedby]': '_config?.ariaDescribedBy || null',
'[@slideDialog]': '_state',
'(@slideDialog.done)': '_onAnimationDone($event)',
},
Expand Down
11 changes: 10 additions & 1 deletion src/lib/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ describe('MdDialog', () => {
expect(dialogContainerElement.getAttribute('role')).toBe('alertdialog');
});

it('should apply the specified `aria-describedby`', () => {
dialog.open(PizzaMsg, { ariaDescribedBy: 'description-element' });

viewContainerFixture.detectChanges();

let dialogContainerElement = overlayContainerElement.querySelector('md-dialog-container')!;
expect(dialogContainerElement.getAttribute('aria-describedby')).toBe('description-element');
});

it('should close a dialog and get back a result', async(() => {
let dialogRef = dialog.open(PizzaMsg, { viewContainerRef: testViewContainerRef });
let afterCloseCallback = jasmine.createSpy('afterClose callback');
Expand Down Expand Up @@ -666,7 +675,7 @@ describe('MdDialog', () => {
});
}));

it('should set the aria-labelled by attribute to the id of the title', async(() => {
it('should set the aria-labelledby attribute to the id of the title', async(() => {
let title = overlayContainerElement.querySelector('[md-dialog-title]')!;
let container = overlayContainerElement.querySelector('md-dialog-container')!;

Expand Down