React-native-google-places-autocomplete: Sample code with real API fetches correctly, but nothing happens on press

Created on 18 Jan 2021  路  4Comments  路  Source: FaridSafi/react-native-google-places-autocomplete

I am not using Expo. Code snippet:
<View style={{width: 300, height: 200, zIndex: 2}}> <GooglePlacesAutocomplete placeholder="Search" fetchDetails={true} onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true console.log(data, details); }} query={{ key: googleAPIKey, language: 'en', }} /> </View>
Typing into the inputfield correctly populates a dropdown menu of options, but clicking an option in the dropdown simply makes the dropdown go away. The inputfield remains as though nothing was selected, and "onPress" never fires. Im on iOS simulator on the latest Big Sur.

question

Most helpful comment

If you have the component inside an ScrollView, add the property keyboardShouldPersistTaps="handled" to the ScrollView

All 4 comments

I tested the code you provided, and it works for me. I'm guessing that you have something further up the tree that is blocking presses.

Closing for now, as this doesn't follow the issue template properly and this doesn't appear to be a problem with the library itself.

Might be related to using an M1 macbook then, as I have already run into other issues due to that.

If you have the component inside an ScrollView, add the property keyboardShouldPersistTaps="handled" to the ScrollView

If issue still persist, then check if your parent component is Flatlist or Scrollview. if yes then add
keyboardShouldPersistTaps={'always'}.
this will resolve OnPress @oscadev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RajanPN picture RajanPN  路  3Comments

diegothucao picture diegothucao  路  3Comments

biks152207 picture biks152207  路  4Comments

GervaisYO picture GervaisYO  路  4Comments

tgreco picture tgreco  路  3Comments