Skip to content

update widget aria label on title switch #251017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/list/listPaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PagedAccessibilityProvider<T> implements IListAccessibilityProvider<number
private accessibilityProvider: IListAccessibilityProvider<T>
) { }

getWidgetAriaLabel(): string {
getWidgetAriaLabel() {
return this.accessibilityProvider.getWidgetAriaLabel();
}

Expand Down
9 changes: 7 additions & 2 deletions src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ export interface IStyleController {

export interface IListAccessibilityProvider<T> extends IListViewAccessibilityProvider<T> {
getAriaLabel(element: T): string | IObservable<string> | null;
getWidgetAriaLabel(): string;
getWidgetAriaLabel(): string | IObservable<string>;
getWidgetRole?(): AriaRole;
getAriaLevel?(element: T): number | undefined;
onDidChangeActiveDescendant?: Event<void>;
Expand Down Expand Up @@ -1530,7 +1530,12 @@ export class List<T> implements ISpliceable<T>, IDisposable {
this.onDidChangeSelection(this._onSelectionChange, this, this.disposables);

if (this.accessibilityProvider) {
this.ariaLabel = this.accessibilityProvider.getWidgetAriaLabel();
const ariaLabel = this.accessibilityProvider.getWidgetAriaLabel();
const observable = (ariaLabel && typeof ariaLabel !== 'string') ? ariaLabel : constObservable(ariaLabel);

this.disposables.add(autorun(reader => {
this.ariaLabel = reader.readObservable(observable);
}));
}

if (this._options.multipleSelectionSupport !== false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { IListAccessibilityProvider } from '../../../../../../base/browser/ui/li
import { ITreeNode, ITreeRenderer } from '../../../../../../base/browser/ui/tree/tree.js';
import { FuzzyScore } from '../../../../../../base/common/filters.js';
import { DisposableStore } from '../../../../../../base/common/lifecycle.js';
import { observableValue } from '../../../../../../base/common/observable.js';
import { localize } from '../../../../../../nls.js';
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
import { WorkbenchObjectTree } from '../../../../../../platform/list/browser/listService.js';
import { DebugExpressionRenderer } from '../../../../debug/browser/debugExpressionRenderer.js';
import { INotebookVariableElement } from './notebookVariablesDataSource.js';
import { NotebookVariablesView } from './notebookVariablesView.js';

const $ = dom.$;
const MAX_VALUE_RENDER_LENGTH_IN_VIEWLET = 1024;
Expand Down Expand Up @@ -86,8 +88,14 @@ export class NotebookVariableRenderer implements ITreeRenderer<INotebookVariable

export class NotebookVariableAccessibilityProvider implements IListAccessibilityProvider<INotebookVariableElement> {

getWidgetAriaLabel(): string {
return localize('debugConsole', "Notebook Variables");
private _widgetAriaLabel = observableValue('widgetAriaLabel', NotebookVariablesView.NOTEBOOK_TITLE.value);

getWidgetAriaLabel() {
return this._widgetAriaLabel;
}

updateWidgetAriaLabel(label: string): void {
this._widgetAriaLabel.set(label, undefined);
}

getAriaLabel(element: INotebookVariableElement): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class NotebookVariablesView extends ViewPane {
private tree: WorkbenchAsyncDataTree<INotebookScope | IEmptyScope, INotebookVariableElement> | undefined;
private activeNotebook: NotebookTextModel | undefined;
private readonly dataSource: NotebookVariableDataSource;
private readonly accessibilityProvider: NotebookVariableAccessibilityProvider;

private updateScheduler: RunOnceScheduler;

Expand Down Expand Up @@ -73,6 +74,7 @@ export class NotebookVariablesView extends ViewPane {
this._register(this.notebookExecutionStateService.onDidChangeExecution(this.handleExecutionStateChange.bind(this)));
this._register(this.editorService.onDidCloseEditor((e) => this.handleCloseEditor(e)));

this.accessibilityProvider = new NotebookVariableAccessibilityProvider();
this.handleActiveEditorChange(false);

this.dataSource = new NotebookVariableDataSource(this.notebookKernelService);
Expand All @@ -91,7 +93,7 @@ export class NotebookVariablesView extends ViewPane {
[this.instantiationService.createInstance(NotebookVariableRenderer)],
this.dataSource,
{
accessibilityProvider: new NotebookVariableAccessibilityProvider(),
accessibilityProvider: this.accessibilityProvider,
identityProvider: { getId: (e: INotebookVariableElement) => e.id },
});

Expand Down Expand Up @@ -150,8 +152,10 @@ export class NotebookVariablesView extends ViewPane {

if (isCompositeNotebookEditorInput(editor.input)) {
this.updateTitle(NotebookVariablesView.REPL_TITLE.value);
this.accessibilityProvider.updateWidgetAriaLabel(NotebookVariablesView.REPL_TITLE.value);
} else {
this.updateTitle(NotebookVariablesView.NOTEBOOK_TITLE.value);
this.accessibilityProvider.updateWidgetAriaLabel(NotebookVariablesView.NOTEBOOK_TITLE.value);
}

if (doUpdate) {
Expand Down
Loading