File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,20 +153,21 @@ export default function AddressInput(props: AddressInputProps) {
153153 saveRecentLocation ( item . mainText , item . secondText , item . point )
154154 }
155155 }
156- // Enter: focus next address input, or blur if last
157- if ( event . key === 'Enter' ) {
158- const next = document
159- . querySelector < HTMLElement > ( '[data-search-box]' ) !
160- . querySelectorAll < HTMLInputElement > ( 'input[type="text"]' ) [ props . index + 1 ]
161- if ( next ) next . focus ( )
162- else searchInput . current ! . blur ( )
163- }
156+ if ( event . key === 'Enter' ) focusNextOrBlur ( )
164157 break
165158 }
166159 } ,
167160 [ autocompleteItems , highlightedResult ] ,
168161 )
169162
163+ const focusNextOrBlur = ( ) => {
164+ const next = document
165+ . querySelector < HTMLElement > ( '[data-search-box]' ) !
166+ . querySelectorAll < HTMLInputElement > ( 'input[type="text"]' ) [ props . index + 1 ]
167+ if ( next ) next . focus ( )
168+ else searchInput . current ! . blur ( )
169+ }
170+
170171 // the "fullscreen" css is only defined for smallscreen
171172 const containerClass = hasFocus ? styles . fullscreen : ''
172173 const type = props . point . type
@@ -308,7 +309,7 @@ export default function AddressInput(props: AddressInputProps) {
308309 handlePoiSearch ( poiSearch , item . result , props . map )
309310 setText ( item . result . text ( item . result . poi ) )
310311 }
311- searchInput . current ! . blur ( ) // see also AutocompleteEntry->onMouseDown
312+ focusNextOrBlur ( )
312313 } }
313314 onClearRecents = { ( ) => {
314315 clearRecentLocations ( )
You can’t perform that action at this time.
0 commit comments