Skip to content

Commit 73bf9d3

Browse files
committed
list: announce once element typing is done
1 parent 4e80e2f commit 73bf9d3

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ class TypeLabelController<T> implements IDisposable {
394394
const onInput = Event.reduce<string | null, string | null>(Event.any(onChar, onClear), (r, i) => i === null ? null : ((r || '') + i));
395395

396396
onInput(this.onInput, this, this.enabledDisposables);
397+
onClear(this.onClear, this, this.enabledDisposables);
397398

398399
this.enabled = true;
399400
this.triggered = false;
@@ -409,6 +410,16 @@ class TypeLabelController<T> implements IDisposable {
409410
this.triggered = false;
410411
}
411412

413+
private onClear(): void {
414+
const focus = this.list.getFocus();
415+
if (focus.length > 0) {
416+
const ariaLabel = this.list.options.accessibilityProvider?.getAriaLabel(this.list.element(focus[0]));
417+
if (ariaLabel) {
418+
alert(ariaLabel);
419+
}
420+
}
421+
}
422+
412423
private onInput(word: string | null): void {
413424
if (!word) {
414425
this.state = TypeLabelControllerState.Idle;
@@ -429,14 +440,6 @@ class TypeLabelController<T> implements IDisposable {
429440
if (typeof labelStr === 'undefined' || matchesPrefix(word, labelStr)) {
430441
this.list.setFocus([index]);
431442
this.list.reveal(index);
432-
433-
if (index === start) {
434-
// Focus did not change with typing, re-announce element https://github.com/microsoft/vscode/issues/95961
435-
const ariaLabel = this.list.options.accessibilityProvider?.getAriaLabel(this.list.element(index));
436-
if (ariaLabel) {
437-
alert(ariaLabel);
438-
}
439-
}
440443
return;
441444
}
442445
}

0 commit comments

Comments
 (0)