Skip to content

Commit c58d92d

Browse files
authored
add a11y hint to navigate to kb editor results (#309074)
1 parent 023cc9a commit c58d92d

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const configuration: IConfigurationNode = {
154154
...baseVerbosityProperty
155155
},
156156
[AccessibilityVerbositySettingId.KeybindingsEditor]: {
157-
description: localize('verbosity.keybindingsEditor.description', 'Provide information about how to change a keybinding in the keybindings editor when a row is focused.'),
157+
description: localize('verbosity.keybindingsEditor.description', 'Provide information about how to change a keybinding in the keybindings editor when a row is focused and how to navigate to the results table.'),
158158
...baseVerbosityProperty
159159
},
160160
[AccessibilityVerbositySettingId.Notebook]: {

src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,13 @@ export class KeybindingsEditor extends EditorPane<IKeybindingsEditorMemento> imp
337337
this.ariaLabelElement = DOM.append(parent, DOM.$(''));
338338
this.ariaLabelElement.setAttribute('id', 'keybindings-editor-aria-label-element');
339339
this.ariaLabelElement.setAttribute('aria-live', 'assertive');
340+
this.ariaLabelElement.style.position = 'absolute';
341+
this.ariaLabelElement.style.width = '1px';
342+
this.ariaLabelElement.style.height = '1px';
343+
this.ariaLabelElement.style.overflow = 'hidden';
344+
this.ariaLabelElement.style.clip = 'rect(1px, 1px, 1px, 1px)';
345+
this.ariaLabelElement.style.clipPath = 'inset(50%)';
346+
this.ariaLabelElement.style.whiteSpace = 'nowrap';
340347
}
341348

342349
private createOverlayContainer(parent: HTMLElement): void {
@@ -602,8 +609,9 @@ export class KeybindingsEditor extends EditorPane<IKeybindingsEditorMemento> imp
602609
if (this.keybindingsEditorModel) {
603610
const filter = this.searchWidget.getValue();
604611
const keybindingsEntries: IKeybindingItemEntry[] = this.keybindingsEditorModel.fetch(filter, this.sortByPrecedenceAction.checked);
605-
this.accessibilityService.alert(localize('foundResults', "{0} results", keybindingsEntries.length));
606-
this.ariaLabelElement.setAttribute('aria-label', this.getAriaLabel(keybindingsEntries));
612+
const ariaLabel = this.getAriaLabel(keybindingsEntries);
613+
this.accessibilityService.alert(ariaLabel);
614+
this.ariaLabelElement.textContent = ariaLabel;
607615

608616
if (keybindingsEntries.length === 0) {
609617
this.latestEmptyFilters.push(filter);
@@ -634,11 +642,19 @@ export class KeybindingsEditor extends EditorPane<IKeybindingsEditorMemento> imp
634642
}
635643

636644
private getAriaLabel(keybindingsEntries: IKeybindingItemEntry[]): string {
645+
let label: string;
637646
if (this.sortByPrecedenceAction.checked) {
638-
return localize('show sorted keybindings', "Showing {0} Keybindings in precedence order", keybindingsEntries.length);
647+
label = localize('show sorted keybindings', "Showing {0} Keybindings in precedence order", keybindingsEntries.length);
639648
} else {
640-
return localize('show keybindings', "Showing {0} Keybindings in alphabetical order", keybindingsEntries.length);
649+
label = localize('show keybindings', "Showing {0} Keybindings in alphabetical order", keybindingsEntries.length);
641650
}
651+
if (this.configurationService.getValue(AccessibilityVerbositySettingId.KeybindingsEditor)) {
652+
const kb = this.keybindingsService.lookupKeybinding('widgetNavigation.focusNext')?.getAriaLabel();
653+
if (kb) {
654+
label += '. ' + localize('navigateToResults', "Use {0} to navigate to the results table.", kb);
655+
}
656+
}
657+
return label;
642658
}
643659

644660
private layoutKeybindingsTable(): void {

0 commit comments

Comments
 (0)