Skip to content

Commit 578c3f0

Browse files
authored
Implement checkbox aria info (microsoft#182754)
Part of microsoft#116141
1 parent 327bf4d commit 578c3f0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/vs/workbench/api/common/extHostTreeViews.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { IMarkdownString } from 'vs/base/common/htmlContent';
2424
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
2525
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
2626
import { ITreeViewsDnDService, TreeViewsDnDService } from 'vs/editor/common/services/treeViewsDnd';
27+
import { IAccessibilityInformation } from 'vs/platform/accessibility/common/accessibility';
2728

2829
type TreeItemHandle = string;
2930

@@ -768,14 +769,15 @@ class ExtHostTreeView<T> extends Disposable {
768769
}
769770
let checkboxState: TreeItemCheckboxState;
770771
let tooltip: string | undefined = undefined;
772+
let accessibilityInformation: IAccessibilityInformation | undefined = undefined;
771773
if (typeof extensionTreeItem.checkboxState === 'number') {
772774
checkboxState = extensionTreeItem.checkboxState;
773-
}
774-
else {
775+
} else {
775776
checkboxState = extensionTreeItem.checkboxState.state;
776777
tooltip = extensionTreeItem.checkboxState.tooltip;
778+
accessibilityInformation = extensionTreeItem.checkboxState.accessibilityInformation;
777779
}
778-
return { isChecked: checkboxState === TreeItemCheckboxState.Checked, tooltip };
780+
return { isChecked: checkboxState === TreeItemCheckboxState.Checked, tooltip, accessibilityInformation };
779781
}
780782

781783
private validateTreeItem(extensionTreeItem: vscode.TreeItem) {

src/vs/workbench/browser/parts/views/checkbox.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class TreeItemCheckbox extends Disposable {
5656
icon: node.checkbox.isChecked ? Codicon.check : undefined,
5757
...defaultToggleStyles
5858
});
59-
59+
this.setAccessibilityInformation(node.checkbox);
6060
this.toggle.domNode.classList.add(TreeItemCheckbox.checkboxClass);
6161
DOM.append(this.checkboxContainer, this.toggle.domNode);
6262
this.registerListener(node);
@@ -78,6 +78,7 @@ export class TreeItemCheckbox extends Disposable {
7878
node.checkbox.isChecked = this.toggle.checked;
7979
this.toggle.setIcon(this.toggle.checked ? Codicon.check : undefined);
8080
this.toggle.setTitle(this.createCheckboxTitle(node.checkbox));
81+
this.setAccessibilityInformation(node.checkbox);
8182
this.checkboxStateHandler.setCheckboxState(node);
8283
}
8384
}
@@ -87,6 +88,15 @@ export class TreeItemCheckbox extends Disposable {
8788
checkbox.isChecked ? localize('checked', 'Checked') : localize('unchecked', 'Unchecked');
8889
}
8990

91+
private setAccessibilityInformation(checkbox: ITreeItemCheckboxState) {
92+
if (this.toggle && checkbox.accessibilityInformation) {
93+
this.toggle.domNode.ariaLabel = checkbox.accessibilityInformation.label;
94+
if (checkbox.accessibilityInformation.role) {
95+
this.toggle.domNode.role = checkbox.accessibilityInformation.role;
96+
}
97+
}
98+
}
99+
90100
private removeCheckbox() {
91101
const children = this.checkboxContainer.children;
92102
for (const child of children) {

src/vs/workbench/common/views.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ export type TreeCommand = Command & { originalId?: string };
756756
export interface ITreeItemCheckboxState {
757757
isChecked: boolean;
758758
tooltip?: string;
759+
accessibilityInformation?: IAccessibilityInformation;
759760
}
760761

761762
export interface ITreeItem {

0 commit comments

Comments
 (0)