@@ -395,6 +395,31 @@ export const AriaAutocompleteTests = ({renderers, setup, prefix, ariaPattern = '
395
395
expect ( actionListener ) . toHaveBeenCalledTimes ( 0 ) ;
396
396
} ) ;
397
397
} ) ;
398
+
399
+ it ( 'should not autofocus the first item if backspacing from a list state where there are only disabled items' , async function ( ) {
400
+ let { getByRole} = ( renderers . disabledItems ! ) ( ) ;
401
+ let input = getByRole ( 'searchbox' ) ;
402
+ let menu = getByRole ( collectionNodeRole ) ;
403
+ let options = within ( menu ) . getAllByRole ( collectionItemRole ) ;
404
+ expect ( options [ 1 ] ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
405
+
406
+ await user . tab ( ) ;
407
+ expect ( document . activeElement ) . toBe ( input ) ;
408
+ await user . keyboard ( 'r' ) ;
409
+ act ( ( ) => jest . runAllTimers ( ) ) ;
410
+ options = within ( menu ) . getAllByRole ( collectionItemRole ) ;
411
+ expect ( options ) . toHaveLength ( 1 ) ;
412
+ expect ( input ) . not . toHaveAttribute ( 'aria-activedescendant' ) ;
413
+ expect ( options [ 0 ] ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
414
+
415
+ await user . keyboard ( '{Backspace}' ) ;
416
+ act ( ( ) => jest . runAllTimers ( ) ) ;
417
+ options = within ( menu ) . getAllByRole ( collectionItemRole ) ;
418
+ expect ( input ) . not . toHaveAttribute ( 'aria-activedescendant' ) ;
419
+ await user . keyboard ( '{ArrowDown}' ) ;
420
+ act ( ( ) => jest . runAllTimers ( ) ) ;
421
+ expect ( input ) . toHaveAttribute ( 'aria-activedescendant' , options [ 0 ] . id ) ;
422
+ } ) ;
398
423
}
399
424
400
425
let filterTests = ( renderer ) => {
0 commit comments