@@ -174,6 +174,9 @@ export default function AddressInput(props: AddressInputProps) {
174174 const lonlat = toLonLat ( getMap ( ) . getView ( ) . getCenter ( ) ! )
175175 const biasCoord = { lng : lonlat [ 0 ] , lat : lonlat [ 1 ] }
176176
177+ // do not focus on mobile as we would hide the map with the "input"-view
178+ const focusFirstInput = props . index == 0 && ! isSmallScreen
179+
177180 return (
178181 < div className = { containerClass } >
179182 < div
@@ -201,7 +204,7 @@ export default function AddressInput(props: AddressInputProps) {
201204 style = { props . moveStartIndex == props . index ? { borderWidth : '2px' , margin : '-1px' } : { } }
202205 className = { styles . input }
203206 type = "text"
204- autoFocus = { props . index == 0 }
207+ autoFocus = { focusFirstInput }
205208 ref = { searchInput }
206209 autoComplete = "off"
207210 onChange = { e => {
@@ -219,7 +222,7 @@ export default function AddressInput(props: AddressInputProps) {
219222 } }
220223 onBlur = { ( ) => {
221224 setHasFocus ( false )
222- if ( ! isSmallScreen ) hideSuggestions ( ) // see #398
225+ hideSuggestions ( )
223226 } }
224227 value = { text }
225228 placeholder = { tr (
@@ -230,11 +233,11 @@ export default function AddressInput(props: AddressInputProps) {
230233 < PlainButton
231234 style = { text . length == 0 ? { display : 'none' } : { } }
232235 className = { styles . btnInputClear }
236+ // no onClick because otherwise focus would be lost before button receives click
233237 onMouseDown = { ( e ) => {
234238 e . preventDefault ( ) // do not lose focus and close mobile-input view when clicked
235239 setText ( '' )
236240 props . onChange ( '' )
237- searchInput . current ! . focus ( )
238241 } }
239242 >
240243 < Cross />
@@ -243,6 +246,7 @@ export default function AddressInput(props: AddressInputProps) {
243246 < PlainButton
244247 style = { text . length == 0 && hasFocus ? { } : { display : 'none' } }
245248 className = { styles . btnCurrentLocation }
249+ // no onClick because otherwise focus would be lost before button receives click
246250 onMouseDown = { ( e ) => {
247251 // here it is desired to close mobile-input view when clicked
248252 onCurrentLocationSelected ( props . onAddressSelected )
0 commit comments