File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,13 @@ export default class Combobox {
5959 const focusEl = Array . from ( this . list . querySelectorAll < HTMLElement > ( '[aria-selected="true"]' ) ) . filter ( visible ) [ 0 ]
6060 const els = Array . from ( this . list . querySelectorAll < HTMLElement > ( '[role="option"]' ) ) . filter ( visible )
6161 const focusIndex = els . indexOf ( focusEl )
62+
63+ if ( ( focusIndex === els . length - 1 && indexDiff === 1 ) || ( focusIndex === 0 && indexDiff === - 1 ) ) {
64+ this . clearSelection ( )
65+ this . input . focus ( )
66+ return
67+ }
68+
6269 let indexOfItem = indexDiff === 1 ? 0 : els . length - 1
6370 if ( focusEl && focusIndex >= 0 ) {
6471 const newIndex = focusIndex + indexDiff
Original file line number Diff line number Diff line change @@ -115,13 +115,20 @@ describe('combobox-nav', function() {
115115 click ( document . getElementById ( 'wall-e' ) )
116116
117117 press ( input , 'ArrowDown' )
118+ assert . equal ( options [ 5 ] . getAttribute ( 'aria-selected' ) , 'true' )
119+ assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'link' )
120+
121+ press ( input , 'ArrowDown' )
122+ assert ( ! list . querySelector ( '[aria-selected=true]' ) , 'Nothing should be selected' )
123+ assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected' )
124+
118125 press ( input , 'ArrowDown' )
119126 assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
120127 assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
121128
122129 press ( input , 'ArrowUp' )
123- assert . equal ( options [ 5 ] . getAttribute ( ' aria-selected') , 'true ' )
124- assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'link ' )
130+ assert ( ! list . querySelector ( '[ aria-selected=true] ') , 'Nothing should be selected ' )
131+ assert ( ! input . hasAttribute ( 'aria-activedescendant' ) , 'Nothing should be selected ' )
125132
126133 press ( input , 'ArrowDown' )
127134 press ( input , 'ArrowDown' )
You can’t perform that action at this time.
0 commit comments