React-native-google-places-autocomplete: Bug Report: setaddressText using ref should trigger search

Created on 11 Nov 2020  路  8Comments  路  Source: FaridSafi/react-native-google-places-autocomplete

Describe the bug

I am saving recently searched terms in my state and when user clicks on one of the recent searches, I do
this.autoCompleteRef.setAddressText(this.state.recentSearch). This updates the text input value but the search is not triggered. I have to press one more key to see the search results from place autocomplete api

Reproduction - (required - issue will be closed without this)

Steps to reproduce the behavior - a minimal reproducible code example, link to a snack or a repository.

Please provide a FULLY REPRODUCIBLE example.


Click to expand!

```js
ref={comp => (this.autoCompleteRef = comp)}
placeholder="Search"
styles={{textInput: {borderBottomColor: "#4a4a4a", borderBottomWidth: 1, backgroundColor: 'transparent'}}}
onPress={(data, details = null) => {
// 'details' is provided when fetchDetails = true
console.log(data);
console.log(details);
}}
query={{
key: 'key',
language: 'en',
components: 'country:in',
}}
currentLocation={true}
currentLocationLabel="Use your current location"
nearbyPlacesAPI="GoogleReverseGeocoding"
textInputProps={{onBlur: () => {}}}
fetchDetails //details.geometry.location - gives lat, lng
/>
handleRecentLocationClick = (desc) => {
this.autoCompleteRef.setAddressText(desc)
this.autoCompleteRef.focus()
}

```

_Please remember to remove you google API key from the code you provide here_

Additional context

  • Library Version: [e.g. 1.4.2]
  • React Native Version: [e.g. 0.62.2]

  • [ ] iOS

  • [x] Android
  • [ ] Web

If you are using expo please indicate here:

  • [ ] I am using expo

Add any other context about the problem here, screenshots etc

bug

Most helpful comment

Does anyone found a solution for this bug?

All 8 comments

You need this.autoCompleteRef.triggerFocus() before version 2.

https://github.com/FaridSafi/react-native-google-places-autocomplete/releases/tag/v2.0.0

Hello @bell-steven i am on version 2.0.3
"react-native-google-places-autocomplete": "^2.0.3"

Ok. Can you try using version 2.1.1. There were some changes in v2.1.0 that may have addressed the issue.

Ok. Can you try using version 2.1.1. There were some changes in v2.1.0 that may have addressed the issue.

v 2.1.1 here and got the same issue. The textinput is updated, but the search is not triggered.

Ok. Can you try using version 2.1.1. There were some changes in v2.1.0 that may have addressed the issue.

i am having the same issue as well. Textinput triggered, but search not.

Same here using v2.1.2.

Is there any solution for this bug? The same issue I am facing search is not triggered with a predefined text.

Does anyone found a solution for this bug?

Was this page helpful?
0 / 5 - 0 ratings