Skip to content

Commit fce3153

Browse files
authored
Merge pull request microsoft#188213 from microsoft/aamunger/notebookAccessibility
aria label with accessibility help hint in notebooks
2 parents b008a7e + 7c2969b commit fce3153

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ import { INotebookLoggingService } from 'vs/workbench/contrib/notebook/common/no
9090
import { Schemas } from 'vs/base/common/network';
9191
import { DropIntoEditorController } from 'vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController';
9292
import { CopyPasteController } from 'vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
93+
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
94+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
9395

9496
const $ = DOM.$;
9597

@@ -284,6 +286,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
284286
@INotebookExecutionStateService notebookExecutionStateService: INotebookExecutionStateService,
285287
@IEditorProgressService private editorProgressService: IEditorProgressService,
286288
@INotebookLoggingService readonly logService: INotebookLoggingService,
289+
@IKeybindingService readonly keybindingService: IKeybindingService
287290
) {
288291
super();
289292

@@ -851,6 +854,17 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
851854
this._listDelegate = this.instantiationService.createInstance(NotebookCellListDelegate);
852855
this._register(this._listDelegate);
853856

857+
const createNotebookAriaLabel = () => {
858+
const keybinding = this.keybindingService.lookupKeybinding('editor.action.accessibilityHelp')?.getLabel();
859+
860+
if (this.configurationService.getValue(AccessibilityVerbositySettingId.Notebook)) {
861+
return keybinding
862+
? nls.localize('notebookTreeAriaLabelHelp', "Notebook\nUse {0} for accessibility help", keybinding)
863+
: nls.localize('notebookTreeAriaLabelHelpNoKb', "Notebook\nRun the Open Accessibility Help command for more information", keybinding);
864+
}
865+
return nls.localize('notebookTreeAriaLabel', "Notebook");
866+
};
867+
854868
this._list = this.instantiationService.createInstance(
855869
NotebookCellList,
856870
'NotebookCellList',
@@ -904,9 +918,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
904918

905919
return '';
906920
},
907-
getWidgetAriaLabel() {
908-
return nls.localize('notebookTreeAriaLabel', "Notebook");
909-
}
921+
getWidgetAriaLabel: createNotebookAriaLabel
910922
},
911923
},
912924
);
@@ -987,6 +999,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
987999
}));
9881000

9891001
this._registerNotebookActionsToolbar();
1002+
1003+
this._register(this.configurationService.onDidChangeConfiguration(e => {
1004+
if (e.affectsConfiguration(AccessibilityVerbositySettingId.Notebook)) {
1005+
this._list.ariaLabel = createNotebookAriaLabel();
1006+
}
1007+
}));
9901008
}
9911009

9921010
private showListContextMenu(e: IListContextMenuEvent<CellViewModel>) {

src/vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface INotebookCellList {
4343
length: number;
4444
rowsContainer: HTMLElement;
4545
scrollableElement: HTMLElement;
46+
ariaLabel: string;
4647
readonly onDidRemoveOutputs: Event<readonly ICellOutputViewModel[]>;
4748
readonly onDidHideOutputs: Event<readonly ICellOutputViewModel[]>;
4849
readonly onDidRemoveCellsFromView: Event<readonly ICellViewModel[]>;

0 commit comments

Comments
 (0)