@@ -26,6 +26,7 @@ import { CombinedSpliceable } from 'vs/base/browser/ui/list/splice';
2626import { clamp } from 'vs/base/common/numbers' ;
2727import { matchesPrefix } from 'vs/base/common/filters' ;
2828import { IDragAndDropData } from 'vs/base/browser/dnd' ;
29+ import { alert } from 'vs/base/browser/ui/aria/aria' ;
2930
3031interface ITraitChangeEvent {
3132 indexes : number [ ] ;
@@ -344,6 +345,7 @@ class TypeLabelController<T> implements IDisposable {
344345
345346 private automaticKeyboardNavigation = true ;
346347 private triggered = false ;
348+ private previouslyFocused = - 1 ;
347349
348350 private readonly enabledDisposables = new DisposableStore ( ) ;
349351 private readonly disposables = new DisposableStore ( ) ;
@@ -393,6 +395,7 @@ class TypeLabelController<T> implements IDisposable {
393395 const onInput = Event . reduce < string | null , string | null > ( Event . any ( onChar , onClear ) , ( r , i ) => i === null ? null : ( ( r || '' ) + i ) ) ;
394396
395397 onInput ( this . onInput , this , this . enabledDisposables ) ;
398+ onClear ( this . onClear , this , this . enabledDisposables ) ;
396399
397400 this . enabled = true ;
398401 this . triggered = false ;
@@ -408,6 +411,19 @@ class TypeLabelController<T> implements IDisposable {
408411 this . triggered = false ;
409412 }
410413
414+ private onClear ( ) : void {
415+ const focus = this . list . getFocus ( ) ;
416+ if ( focus . length > 0 && focus [ 0 ] === this . previouslyFocused ) {
417+ // List: re-anounce element on typing end since typed keys will interupt aria label of focused element
418+ // Do not announce if there was a focus change at the end to prevent duplication https://github.com/microsoft/vscode/issues/95961
419+ const ariaLabel = this . list . options . accessibilityProvider ?. getAriaLabel ( this . list . element ( focus [ 0 ] ) ) ;
420+ if ( ariaLabel ) {
421+ alert ( ariaLabel ) ;
422+ }
423+ }
424+ this . previouslyFocused = - 1 ;
425+ }
426+
411427 private onInput ( word : string | null ) : void {
412428 if ( ! word ) {
413429 this . state = TypeLabelControllerState . Idle ;
@@ -426,6 +442,7 @@ class TypeLabelController<T> implements IDisposable {
426442 const labelStr = label && label . toString ( ) ;
427443
428444 if ( typeof labelStr === 'undefined' || matchesPrefix ( word , labelStr ) ) {
445+ this . previouslyFocused = start ;
429446 this . list . setFocus ( [ index ] ) ;
430447 this . list . reveal ( index ) ;
431448 return ;
0 commit comments