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 {
59
59
const focusEl = Array . from ( this . list . querySelectorAll < HTMLElement > ( '[aria-selected="true"]' ) ) . filter ( visible ) [ 0 ]
60
60
const els = Array . from ( this . list . querySelectorAll < HTMLElement > ( '[role="option"]' ) ) . filter ( visible )
61
61
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
+
62
69
let indexOfItem = indexDiff === 1 ? 0 : els . length - 1
63
70
if ( focusEl && focusIndex >= 0 ) {
64
71
const newIndex = focusIndex + indexDiff
Original file line number Diff line number Diff line change @@ -115,13 +115,20 @@ describe('combobox-nav', function() {
115
115
click ( document . getElementById ( 'wall-e' ) )
116
116
117
117
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
+
118
125
press ( input , 'ArrowDown' )
119
126
assert . equal ( options [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
120
127
assert . equal ( input . getAttribute ( 'aria-activedescendant' ) , 'baymax' )
121
128
122
129
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 ' )
125
132
126
133
press ( input , 'ArrowDown' )
127
134
press ( input , 'ArrowDown' )
You can’t perform that action at this time.
0 commit comments