From 9bf0af3ea0715d73cfa6440a14f4487028412d74 Mon Sep 17 00:00:00 2001 From: isidor Date: Mon, 20 Jan 2020 16:54:16 +0100 Subject: [PATCH] accessibility: make editor aria labels more concise #88727 --- src/vs/workbench/browser/parts/editor/editorGroupView.ts | 4 ++++ src/vs/workbench/browser/parts/editor/textDiffEditor.ts | 4 ++-- src/vs/workbench/browser/parts/editor/textEditor.ts | 2 +- src/vs/workbench/browser/parts/editor/textResourceEditor.ts | 4 ++-- .../workbench/contrib/files/browser/editors/textFileEditor.ts | 4 ++-- .../contrib/preferences/browser/preferencesEditor.ts | 2 +- .../workbench/services/editor/common/editorGroupsService.ts | 2 ++ src/vs/workbench/test/workbenchTestServices.ts | 1 + 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index 1b15bea8db514..dc80ba41b04c8 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -668,6 +668,10 @@ export class EditorGroupView extends Themable implements IEditorGroupView { return localize('groupLabel', "Group {0}", this._index + 1); } + get ariaLabel(): string { + return localize('groupAriaLabel', "Editor Group {0}", this._index + 1); + } + get disposed(): boolean { return this._disposed; } diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 3dbb5f41ac56f..aaa2387c55bc7 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -217,9 +217,9 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { const inputName = this.input?.getName(); if (this.input?.isReadonly()) { - ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text compare editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text compare editor."); + ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0} readonly compare editor", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly compare editor"); } else { - ariaLabel = inputName ? nls.localize('editableEditorWithInputAriaLabel', "{0}. Text file compare editor.", inputName) : nls.localize('editableEditorAriaLabel', "Text file compare editor."); + ariaLabel = inputName ? nls.localize('editableEditorWithInputAriaLabel', "{0} compare editor", inputName) : nls.localize('editableEditorAriaLabel', "Compare editor"); } return ariaLabel; diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index 1996880cf6bca..25b9dd75088e6 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -104,7 +104,7 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditor { // Apply group information to help identify in which group we are if (ariaLabel) { if (this.group) { - ariaLabel = localize('editorLabelWithGroup', "{0}, {1}.", ariaLabel, this.group.label); + ariaLabel = localize('editorLabelWithGroup', "{0}, {1}", ariaLabel, this.group.ariaLabel); } } diff --git a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts index 04556f511fd4b..e42afeb59651b 100644 --- a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts @@ -107,9 +107,9 @@ export class AbstractTextResourceEditor extends BaseTextEditor { const inputName = this.input?.getName(); if (this.input?.isReadonly()) { - ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text editor."); + ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0} readonly editor", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly editor"); } else { - ariaLabel = inputName ? nls.localize('untitledFileEditorWithInputAriaLabel', "{0}. Untitled file text editor.", inputName) : nls.localize('untitledFileEditorAriaLabel', "Untitled file text editor."); + ariaLabel = inputName ? nls.localize('untitledFileEditorWithInputAriaLabel', "{0} editor", inputName) : nls.localize('untitledFileEditorAriaLabel', "Editor"); } return ariaLabel; diff --git a/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts b/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts index f89c60e8eb25b..13402fd628c10 100644 --- a/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/contrib/files/browser/editors/textFileEditor.ts @@ -239,9 +239,9 @@ export class TextFileEditor extends BaseTextEditor { let ariaLabel: string; if (inputName) { - ariaLabel = nls.localize('fileEditorWithInputAriaLabel', "{0}. Text file editor.", inputName); + ariaLabel = nls.localize('fileEditorWithInputAriaLabel', "{0} editor", inputName); } else { - ariaLabel = nls.localize('fileEditorAriaLabel', "Text file editor."); + ariaLabel = nls.localize('fileEditorAriaLabel', "Editor"); } return ariaLabel; diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts b/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts index 88ef4d2883547..cda7c8dad3d5f 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts @@ -1062,7 +1062,7 @@ export class DefaultPreferencesEditor extends BaseTextEditor { } protected getAriaLabel(): string { - return nls.localize('preferencesAriaLabel', "Default preferences. Readonly text editor."); + return nls.localize('preferencesAriaLabel', "Default preferences. Readonly editor."); } } diff --git a/src/vs/workbench/services/editor/common/editorGroupsService.ts b/src/vs/workbench/services/editor/common/editorGroupsService.ts index ab64d9085c76f..7b4a253d4239c 100644 --- a/src/vs/workbench/services/editor/common/editorGroupsService.ts +++ b/src/vs/workbench/services/editor/common/editorGroupsService.ts @@ -397,6 +397,8 @@ export interface IEditorGroup { */ readonly label: string; + readonly ariaLabel: string; + /** * The active control is the currently visible control of the group. */ diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index a6eb89007ebcb..ad4e8360b6af7 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -770,6 +770,7 @@ export class TestEditorGroupView implements IEditorGroupView { disposed!: boolean; editors: ReadonlyArray = []; label!: string; + ariaLabel!: string; index!: number; whenRestored: Promise = Promise.resolve(undefined); element!: HTMLElement;