From 01a7dfc3894ee3d768498d67d344a0878ec2f1b7 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 7 May 2020 11:50:10 +0200 Subject: [PATCH] list: store previously focused on typeing naviation --- src/vs/base/browser/ui/list/listWidget.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index c9286726313..b271eea461b 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -345,7 +345,7 @@ class TypeLabelController implements IDisposable { private automaticKeyboardNavigation = true; private triggered = false; - private charactersTyped = 0; + private previouslyFocused = -1; private readonly enabledDisposables = new DisposableStore(); private readonly disposables = new DisposableStore(); @@ -413,15 +413,15 @@ class TypeLabelController implements IDisposable { private onClear(): void { const focus = this.list.getFocus(); - if (focus.length > 0 && this.charactersTyped > 1) { + if (focus.length > 0 && focus[0] === this.previouslyFocused) { // List: re-anounce element on typing end since typed keys will interupt aria label of focused element - // Do not announce if only one character typed to avoid duplicate announcment https://github.com/microsoft/vscode/issues/95961 + // Do not announce if there was a focus change at the end to prevent duplication https://github.com/microsoft/vscode/issues/95961 const ariaLabel = this.list.options.accessibilityProvider?.getAriaLabel(this.list.element(focus[0])); if (ariaLabel) { alert(ariaLabel); } } - this.charactersTyped = 0; + this.previouslyFocused = -1; } private onInput(word: string | null): void { @@ -431,7 +431,6 @@ class TypeLabelController implements IDisposable { return; } - this.charactersTyped++; const focus = this.list.getFocus(); const start = focus.length > 0 ? focus[0] : 0; const delta = this.state === TypeLabelControllerState.Idle ? 1 : 0; @@ -443,6 +442,7 @@ class TypeLabelController implements IDisposable { const labelStr = label && label.toString(); if (typeof labelStr === 'undefined' || matchesPrefix(word, labelStr)) { + this.previouslyFocused = start; this.list.setFocus([index]); this.list.reveal(index); return; -- GitLab