@@ -38,7 +38,7 @@ export default class Autocomplete {
38
38
this . results . addEventListener ( 'combobox-commit' , this . onCommit )
39
39
}
40
40
41
- destroy ( ) {
41
+ destroy ( ) : void {
42
42
this . input . removeEventListener ( 'keydown' , this . onKeydown )
43
43
this . input . removeEventListener ( 'focus' , this . onInputFocus )
44
44
this . input . removeEventListener ( 'blur' , this . onInputBlur )
@@ -47,7 +47,7 @@ export default class Autocomplete {
47
47
this . results . removeEventListener ( 'combobox-commit' , this . onCommit )
48
48
}
49
49
50
- onKeydown ( event : KeyboardEvent ) {
50
+ onKeydown ( event : KeyboardEvent ) : void {
51
51
if ( event . key === 'Escape' && this . container . open ) {
52
52
this . container . open = false
53
53
event . stopPropagation ( )
@@ -64,19 +64,19 @@ export default class Autocomplete {
64
64
}
65
65
}
66
66
67
- onInputFocus ( ) {
67
+ onInputFocus ( ) : void {
68
68
this . fetchResults ( )
69
69
}
70
70
71
- onInputBlur ( ) {
71
+ onInputBlur ( ) : void {
72
72
if ( this . interactingWithList ) {
73
73
this . interactingWithList = false
74
74
return
75
75
}
76
76
this . container . open = false
77
77
}
78
78
79
- onCommit ( { target} : Event ) {
79
+ onCommit ( { target} : Event ) : void {
80
80
const selected = target
81
81
if ( ! ( selected instanceof HTMLElement ) ) return
82
82
this . container . open = false
@@ -85,23 +85,23 @@ export default class Autocomplete {
85
85
this . container . value = value
86
86
}
87
87
88
- onResultsMouseDown ( ) {
88
+ onResultsMouseDown ( ) : void {
89
89
this . interactingWithList = true
90
90
}
91
91
92
- onInputChange ( ) {
92
+ onInputChange ( ) : void {
93
93
this . container . removeAttribute ( 'value' )
94
94
this . fetchResults ( )
95
95
}
96
96
97
- identifyOptions ( ) {
97
+ identifyOptions ( ) : void {
98
98
let id = 0
99
99
for ( const el of this . results . querySelectorAll ( '[role="option"]:not([id])' ) ) {
100
100
el . id = `${ this . results . id } -option-${ id ++ } `
101
101
}
102
102
}
103
103
104
- fetchResults ( ) {
104
+ fetchResults ( ) : void {
105
105
const query = this . input . value . trim ( )
106
106
if ( ! query ) {
107
107
this . container . open = false
@@ -132,13 +132,13 @@ export default class Autocomplete {
132
132
} )
133
133
}
134
134
135
- open ( ) {
135
+ open ( ) : void {
136
136
if ( ! this . results . hidden ) return
137
137
this . combobox . start ( )
138
138
this . results . hidden = false
139
139
}
140
140
141
- close ( ) {
141
+ close ( ) : void {
142
142
if ( this . results . hidden ) return
143
143
this . combobox . stop ( )
144
144
this . results . hidden = true
0 commit comments