Skip to content

Commit bd04766

Browse files
committed
use aria-roledescription and use ame aria label between editor and tab
fixes microsoft#94828
1 parent bbaa69e commit bd04766

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/vs/editor/browser/controller/textAreaHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class TextAreaHandler extends ViewPart {
125125
this.textArea.setAttribute('spellcheck', 'false');
126126
this.textArea.setAttribute('aria-label', this._getAriaLabel(options));
127127
this.textArea.setAttribute('role', 'textbox');
128+
this.textArea.setAttribute('aria-roledescription', nls.localize('editor', "editor"));
128129
this.textArea.setAttribute('aria-multiline', 'true');
129130
this.textArea.setAttribute('aria-haspopup', 'false');
130131
this.textArea.setAttribute('aria-autocomplete', 'both');

src/vs/workbench/browser/parts/editor/tabsTitleControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ export class TabsTitleControl extends TitleControl {
845845
name: editor.getName(),
846846
description: editor.getDescription(verbosity),
847847
title: withNullAsUndefined(editor.getTitle(Verbosity.LONG)),
848-
ariaLabel: editor.getTitle(Verbosity.SHORT)
848+
ariaLabel: editor.isReadonly() ? localize('readonlyEditor', "{0} readonly", editor.getTitle(Verbosity.SHORT)) : editor.getTitle(Verbosity.SHORT)
849849
}));
850850

851851
// Shorten labels as needed

src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Action } from 'vs/base/common/actions';
1212
import { VIEWLET_ID, TEXT_FILE_EDITOR_ID, IExplorerService } from 'vs/workbench/contrib/files/common/files';
1313
import { ITextFileService, TextFileOperationError, TextFileOperationResult } from 'vs/workbench/services/textfile/common/textfiles';
1414
import { BaseTextEditor, IEditorConfiguration } from 'vs/workbench/browser/parts/editor/textEditor';
15-
import { EditorOptions, TextEditorOptions, IEditorCloseEvent } from 'vs/workbench/common/editor';
15+
import { EditorOptions, TextEditorOptions, IEditorCloseEvent, Verbosity } from 'vs/workbench/common/editor';
1616
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
1717
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
1818
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
@@ -246,16 +246,8 @@ export class TextFileEditor extends BaseTextEditor {
246246
}
247247

248248
protected getAriaLabel(): string {
249-
const inputName = this.input?.getName();
250-
251-
let ariaLabel: string;
252-
if (this.input?.isReadonly()) {
253-
ariaLabel = inputName ? nls.localize('readonlyFileEditorWithInputAriaLabel', "{0} readonly editor", inputName) : nls.localize('readonlyFileEditorAriaLabel', "Readonly editor");
254-
} else {
255-
ariaLabel = inputName ? nls.localize('fileEditorWithInputAriaLabel', "{0} editor", inputName) : nls.localize('fileEditorAriaLabel', "Editor");
256-
}
257-
258-
return ariaLabel;
249+
const title = this.input?.getTitle(Verbosity.SHORT) || nls.localize('fileEditorAriaLabel', "editor");
250+
return this.input?.isReadonly() ? nls.localize('readonlyEditor', "{0} readonly", title) : title;
259251
}
260252

261253
clearInput(): void {

0 commit comments

Comments
 (0)