Skip to content

Commit

Permalink
accessibility: make editor aria labels more concise
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Jan 20, 2020
1 parent 26f1ebb commit 9bf0af3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/vs/workbench/browser/parts/editor/editorGroupView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/textDiffEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/editor/textEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/textResourceEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ export interface IEditorGroup {
*/
readonly label: string;

readonly ariaLabel: string;

/**
* The active control is the currently visible control of the group.
*/
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/test/workbenchTestServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ export class TestEditorGroupView implements IEditorGroupView {
disposed!: boolean;
editors: ReadonlyArray<IEditorInput> = [];
label!: string;
ariaLabel!: string;
index!: number;
whenRestored: Promise<void> = Promise.resolve(undefined);
element!: HTMLElement;
Expand Down

0 comments on commit 9bf0af3

Please sign in to comment.