File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export default class Combobox {
108
108
const focusIndex = els . indexOf ( focusEl )
109
109
110
110
if ( ( focusIndex === els . length - 1 && indexDiff === 1 ) || ( focusIndex === 0 && indexDiff === - 1 ) ) {
111
- this . resetSelection ( )
111
+ this . clearSelection ( )
112
112
this . input . focus ( )
113
113
return
114
114
}
Original file line number Diff line number Diff line change @@ -340,8 +340,6 @@ describe('combobox-nav', function () {
340
340
<li><del>BB-8</del></li>
341
341
<li id="hubot" role="option">Hubot</li>
342
342
<li id="r2-d2" role="option">R2-D2</li>
343
- <li id="johnny-5" hidden role="option">Johnny 5</li>
344
- <li id="wall-e" role="option" aria-disabled="true">Wall-E</li>
345
343
<li><a href="#link" role="option" id="link">Link</a></li>
346
344
</ul>
347
345
`
@@ -373,6 +371,23 @@ describe('combobox-nav', function () {
373
371
assert . equal ( list . children [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
374
372
} )
375
373
374
+ it ( 'pressing key down off the last item will have no items selected' , ( ) => {
375
+ // Get all visible options in the list
376
+ const options = document . querySelectorAll ( '[role=option]:not([aria-hidden=true])' )
377
+ // Key press down for each item and ensure the next is selected
378
+ for ( let i = 0 ; i < options . length ; i ++ ) {
379
+ if ( i > 0 ) {
380
+ assert . equal ( options [ i - 1 ] . getAttribute ( 'aria-selected' ) , null )
381
+ }
382
+
383
+ assert . equal ( options [ i ] . getAttribute ( 'aria-selected' ) , 'true' )
384
+ press ( input , 'ArrowDown' )
385
+ }
386
+
387
+ const selected = document . querySelectorAll ( '[aria-selected]' )
388
+ assert . equal ( selected . length , 0 )
389
+ } )
390
+
376
391
it ( 'indicates first option when restarted' , ( ) => {
377
392
combobox . stop ( )
378
393
combobox . start ( )
You can’t perform that action at this time.
0 commit comments