Skip to content

Commit 60a6939

Browse files
authored
Make dialog accessible (microsoft#98969)
* test 1 * fixes dialog accessibility
1 parent 9a31486 commit 60a6939

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/vs/base/browser/ui/dialog/dialog.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class Dialog extends Disposable {
7373
this.modal = this.container.appendChild($(`.monaco-dialog-modal-block${options.type === 'pending' ? '.dimmed' : ''}`));
7474
this.shadowElement = this.modal.appendChild($('.dialog-shadow'));
7575
this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
76+
this.element.setAttribute('role', 'dialog');
7677
hide(this.element);
7778

7879
// If no button is provided, default to OK
@@ -109,6 +110,28 @@ export class Dialog extends Disposable {
109110
this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
110111
}
111112

113+
private getAriaLabel(): string {
114+
let typeLabel = nls.localize('dialogInfoMessage', 'Info');
115+
switch (this.options.type) {
116+
case 'error':
117+
nls.localize('dialogErrorMessage', 'Error');
118+
break;
119+
case 'warning':
120+
nls.localize('dialogWarningMessage', 'Warning');
121+
break;
122+
case 'pending':
123+
nls.localize('dialogPendingMessage', 'In Progress');
124+
break;
125+
case 'none':
126+
case 'info':
127+
case 'question':
128+
default:
129+
break;
130+
}
131+
132+
return `${typeLabel}: ${this.message} ${this.options.detail || ''}`;
133+
}
134+
112135
updateMessage(message: string): void {
113136
if (this.messageDetailElement) {
114137
this.messageDetailElement.innerText = message;
@@ -242,7 +265,7 @@ export class Dialog extends Disposable {
242265

243266
this.applyStyles();
244267

245-
this.element.setAttribute('aria-label', this.message);
268+
this.element.setAttribute('aria-label', this.getAriaLabel());
246269
show(this.element);
247270

248271
// Focus first element

0 commit comments

Comments
 (0)