File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -96,10 +96,9 @@ function focusOnOpen(details: Element) {
96
96
const onmousedown = ( ) => ( isMouse = true )
97
97
const onkeydown = ( ) => ( isMouse = false )
98
98
const ontoggle = ( ) => {
99
- autofocus ( details )
100
- if ( details . hasAttribute ( 'open' ) && ! isMouse ) {
101
- focusFirstItem ( details )
102
- }
99
+ if ( ! details . hasAttribute ( 'open' ) ) return
100
+ if ( autofocus ( details ) ) return
101
+ if ( ! isMouse ) focusFirstItem ( details )
103
102
}
104
103
105
104
details . addEventListener ( 'mousedown' , onmousedown )
@@ -128,12 +127,14 @@ function closeCurrentMenu(event: Event) {
128
127
}
129
128
}
130
129
131
- function autofocus ( details : Element ) {
132
- if ( ! details . hasAttribute ( 'open' ) ) return
133
-
130
+ function autofocus ( details : Element ) : boolean {
131
+ if ( ! details . hasAttribute ( 'open' ) ) return false
134
132
const input = details . querySelector ( '[autofocus]' )
135
133
if ( input ) {
136
134
input . focus ( )
135
+ return true
136
+ } else {
137
+ return false
137
138
}
138
139
}
139
140
You can’t perform that action at this time.
0 commit comments