From 199856707ffb829c1599a543215e888f30bacafe Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 1 Jul 2020 13:12:02 +0200 Subject: [PATCH] fixes #101442 --- src/vs/workbench/api/browser/mainThreadStatusBar.ts | 4 +++- src/vs/workbench/browser/parts/statusbar/statusbarPart.ts | 3 +++ src/vs/workbench/contrib/timeline/browser/timelinePane.ts | 6 ++++++ src/vs/workbench/services/statusbar/common/statusbar.ts | 6 ++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/browser/mainThreadStatusBar.ts b/src/vs/workbench/api/browser/mainThreadStatusBar.ts index 09eff1450d0..d50bc8f08eb 100644 --- a/src/vs/workbench/api/browser/mainThreadStatusBar.ts +++ b/src/vs/workbench/api/browser/mainThreadStatusBar.ts @@ -30,12 +30,14 @@ export class MainThreadStatusBar implements MainThreadStatusBarShape { $setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: string | undefined, command: Command | undefined, color: string | ThemeColor | undefined, alignment: MainThreadStatusBarAlignment, priority: number | undefined, accessibilityInformation: IAccessibilityInformation): void { // if there are icons in the text use the tooltip for the aria label let ariaLabel: string; + let role: string | undefined = undefined; if (accessibilityInformation) { ariaLabel = accessibilityInformation.label; + role = accessibilityInformation.role; } else { ariaLabel = text ? text.replace(MainThreadStatusBar.CODICON_REGEXP, (_match, codiconName) => codiconName) : ''; } - const entry: IStatusbarEntry = { text, tooltip, command, color, ariaLabel }; + const entry: IStatusbarEntry = { text, tooltip, command, color, ariaLabel, role }; if (typeof priority === 'undefined') { priority = 0; diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index fe6a54fcbca..fd6e67fbc09 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -765,6 +765,9 @@ class StatusbarEntryItem extends Disposable { this.container.setAttribute('aria-label', entry.ariaLabel); this.labelContainer.setAttribute('aria-label', entry.ariaLabel); } + if (!this.entry || entry.role !== this.entry.role) { + this.labelContainer.setAttribute('role', entry.role || 'button'); + } // Update: Tooltip (on the container, because label can be disabled) if (!this.entry || entry.tooltip !== this.entry.tooltip) { diff --git a/src/vs/workbench/contrib/timeline/browser/timelinePane.ts b/src/vs/workbench/contrib/timeline/browser/timelinePane.ts index 9eb51448f22..7b07eae3303 100644 --- a/src/vs/workbench/contrib/timeline/browser/timelinePane.ts +++ b/src/vs/workbench/contrib/timeline/browser/timelinePane.ts @@ -885,6 +885,12 @@ export class TimelinePane extends ViewPane { } return element.accessibilityInformation ? element.accessibilityInformation.label : localize('timeline.aria.item', "{0}: {1}", element.relativeTime ?? '', element.label); }, + getRole(element: TreeElement): string { + if (isLoadMoreCommand(element)) { + return 'treeitem'; + } + return element.accessibilityInformation && element.accessibilityInformation.role ? element.accessibilityInformation.role : 'treeitem'; + }, getWidgetAriaLabel(): string { return localize('timeline', "Timeline"); } diff --git a/src/vs/workbench/services/statusbar/common/statusbar.ts b/src/vs/workbench/services/statusbar/common/statusbar.ts index 018a049fa47..14a52e61d68 100644 --- a/src/vs/workbench/services/statusbar/common/statusbar.ts +++ b/src/vs/workbench/services/statusbar/common/statusbar.ts @@ -33,6 +33,12 @@ export interface IStatusbarEntry { */ readonly ariaLabel: string; + /** + * Role of the status bar entry which defines how a screen reader interacts with it. + * Default is 'button'. + */ + readonly role?: string; + /** * An optional tooltip text to show when you hover over the entry */ -- GitLab