react-native-google-places-autocomplete
react-native-google-places-autocomplete copied to clipboard
On Press is Working fine on emulator and simulator but not working on Android device
Describe the bug
On Press is Working fine on emulator and simulator but not working on Android device
Reproduction:
Implement GooglePlacesAutocomplete npm as per the documentation, test on emulator and then test on real device
Please provide a FULLY REPRODUCIBLE example.
Click to expand!
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
const GooglePlaceInput = () => {
const HandleOnPress = (data, details = null) => {
console.log('on press clicked');
};
return (
<GooglePlacesAutocomplete
placeholder="Search"
enablePoweredByContainer={false}
onPress={HandleOnPress}
// currentLocation={true}
// currentLocationLabel="Current location"
GooglePlacesDetailsQuery={{
fields: ['formatted_address', 'geometry'],
}}
fetchDetails={true}
keepResultsAfterBlur={true}
filterReverseGeocodingByTypes={[
'locality',
'administrative_area_level_1',
'country',
'street_address',
'postal_code',
'street_number',
]}
query={{
key: '...MY_KEY...',
}}
renderRow={e => (
<View
style={{
flexDirection: 'row',
width: '100%',
}}>
<ICONS.EvilIcons
name="location"
color={'green'}
size={SCALE(25)}
style={{ marginLeft: -5 }}
/>
<Text
title={e.description}
style={{
justifyContent: 'flex-start',
width: '100%',
alignSelf: 'flex-start',
}}
/>
</View>
)}
styles={{
textInputContainer: {
width: '90%',
alignSelf: 'center',
borderBottomColor: 'black',
borderRadius: 50,
padding: 10,
backgroundColor: '#F0F0F0',
},
listView: {
marginTop: 10,
width: '100%',
marginLeft: -35,
},
description: {
width: '100%',
flexWrap: 'wrap',
},
row: {
padding: 13,
width: '100%',
},
textInput: {
width: '100%',
height: '100%',
fontSize: 16,
backgroundColor: '#F0F0F0',
},
}}
/>
);
};
export default GooglePlaceInput;
Please remember to remove you google API key from the code you provide here
Additional context
-
Library Version: ^2.5.1
-
React Native Version: 0.71.5
-
[ ] iOS
-
[x] Android
-
[ ] Web
@MrFarhan try to add prop keepResultsAfterBlur={true}, maybe you use GooglePlace input inside of Modal, or ScrollView
@MrFarhan try to add prop keepResultsAfterBlur={true}, maybe you use GooglePlace input inside of Modal, or ScrollView
Works for me! thank u
if you are using GooglePlaceAutocomplete inside ScrollView then pass prop keyboardShouldPersistTaps="handled" in ScrollView
example:
<ScrollView keyboardShouldPersistTaps="handled" >
<GooglePlacesAutocomplete />
</ScrollView>
thanks @gulsher7 also work on KeyboardAwareScrollView <KeyboardAwareScrollView keyboardShouldPersistTaps={'handled'}>