File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 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 {
108108 const focusIndex = els . indexOf ( focusEl )
109109
110110 if ( ( focusIndex === els . length - 1 && indexDiff === 1 ) || ( focusIndex === 0 && indexDiff === - 1 ) ) {
111- this . resetSelection ( )
111+ this . clearSelection ( )
112112 this . input . focus ( )
113113 return
114114 }
Original file line number Diff line number Diff line change @@ -340,8 +340,6 @@ describe('combobox-nav', function () {
340340 <li><del>BB-8</del></li>
341341 <li id="hubot" role="option">Hubot</li>
342342 <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>
345343 <li><a href="#link" role="option" id="link">Link</a></li>
346344 </ul>
347345 `
@@ -373,6 +371,23 @@ describe('combobox-nav', function () {
373371 assert . equal ( list . children [ 0 ] . getAttribute ( 'aria-selected' ) , 'true' )
374372 } )
375373
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+
376391 it ( 'indicates first option when restarted' , ( ) => {
377392 combobox . stop ( )
378393 combobox . start ( )
You can’t perform that action at this time.
0 commit comments