Skip to content

Commit ee4ccef

Browse files
committed
do not announce if only one character typed to avoid duplicate announcment
1 parent 73bf9d3 commit ee4ccef

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/vs/base/browser/ui/list/listWidget.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ class TypeLabelController<T> implements IDisposable {
345345

346346
private automaticKeyboardNavigation = true;
347347
private triggered = false;
348+
private charactersTyped = 0;
348349

349350
private readonly enabledDisposables = new DisposableStore();
350351
private readonly disposables = new DisposableStore();
@@ -412,12 +413,15 @@ class TypeLabelController<T> implements IDisposable {
412413

413414
private onClear(): void {
414415
const focus = this.list.getFocus();
415-
if (focus.length > 0) {
416+
if (focus.length > 0 && this.charactersTyped > 1) {
417+
// List: re-anounce element on typing end since typed keys will interupt aria label of focused element
418+
// Do not announce if only one character typed to avoid duplicate announcment https://github.com/microsoft/vscode/issues/95961
416419
const ariaLabel = this.list.options.accessibilityProvider?.getAriaLabel(this.list.element(focus[0]));
417420
if (ariaLabel) {
418421
alert(ariaLabel);
419422
}
420423
}
424+
this.charactersTyped = 0;
421425
}
422426

423427
private onInput(word: string | null): void {
@@ -427,6 +431,7 @@ class TypeLabelController<T> implements IDisposable {
427431
return;
428432
}
429433

434+
this.charactersTyped++;
430435
const focus = this.list.getFocus();
431436
const start = focus.length > 0 ? focus[0] : 0;
432437
const delta = this.state === TypeLabelControllerState.Idle ? 1 : 0;

0 commit comments

Comments
 (0)