File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 28
28
const list = document . querySelector ( 'ul' )
29
29
const comboboxController = new Combobox ( input , list )
30
30
31
- function toggleList ( ) {
32
- const hidden = input . value . length === 0
31
+ function toggleList ( show ) {
32
+ const hidden = show === true ? false : input . value . length === 0
33
33
if ( hidden ) {
34
34
comboboxController . stop ( )
35
35
} else {
36
36
comboboxController . start ( )
37
37
}
38
38
list . hidden = hidden
39
39
}
40
- input . addEventListener ( 'input' , toggleList )
41
- input . addEventListener ( 'focus' , toggleList )
40
+ input . addEventListener ( 'keydown' , event => {
41
+ if ( event . key !== 'ArrowDown' || ! list . hidden ) return
42
+ toggleList ( true )
43
+ comboboxController . navigate ( 1 )
44
+ } )
45
+ input . addEventListener ( 'input' , ( ) => toggleList ( ) )
46
+ input . addEventListener ( 'focus' , ( ) => toggleList ( ) )
42
47
input . addEventListener ( 'blur' , ( ) => {
43
48
list . hidden = true
44
49
comboboxController . clearSelection ( )
You can’t perform that action at this time.
0 commit comments