React-native-google-places-autocomplete: Current Location only displays results when Input is in focus

Created on 29 Jan 2020  路  7Comments  路  Source: FaridSafi/react-native-google-places-autocomplete

Clicking on the current Location "blurs" the component which set listViewDisplayed:false.

The results get "loaded", but not displayed until you re-focus the input component.

I'm not sure if this was intentional but it basically means nothing will happen unless the user clicks on the input box again, triggering the _onFocus function again.

I'm trying to find a hack around this:

    } else if (rowData.isCurrentLocation === true) {
      // display loader
      this._enableRowLoader(rowData);

      this.setState({
        text: this._renderDescription( rowData ),
      });

      // this.triggerBlur(); // hide keyboard but not the results
      delete rowData.isLoading;
      this.getCurrentLocation();

    } else {

I commented out // this.triggerBlur(); // hide keyboard but not the results and it works now as I expect it to.

Why was the blur added and is this the expected behavior?

bug has pr

Most helpful comment

my Current Location solution

<GooglePlacesAutocomplete
  currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
  currentLocationLabel="Current Location"
  nearbyPlacesAPI="GoogleReverseGeocoding"
  textInputProps={{ onBlur: () => {} }}
..../>

All 7 comments

I believe you need to change:

             this.setState({
                dataSource: this.buildRowsFromResults(results),
              });

to

             this.setState({
                dataSource: this.buildRowsFromResults(results),
                listViewDisplayed: true,
              });

on _requestNearby

Even i am facing the same issue..

So i had the same issue. I even copied the same code from the current github repo.
Strange .
Its really nice to see people contributing and updating it

textInputProps={{ onBlur: _.noop() }}

whereas _ is from lodash

this solved this problem for me

my Current Location solution

<GooglePlacesAutocomplete
  currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
  currentLocationLabel="Current Location"
  nearbyPlacesAPI="GoogleReverseGeocoding"
  textInputProps={{ onBlur: () => {} }}
..../>

currentLocation={true} // Will add a 'Curr

This works to me

fixed in 1.7.0.

Was this page helpful?
0 / 5 - 0 ratings