Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectSuggest() work with autoActivateFirstSuggest #423

Closed
heathervv opened this issue Feb 19, 2019 · 1 comment
Closed

selectSuggest() work with autoActivateFirstSuggest #423

heathervv opened this issue Feb 19, 2019 · 1 comment

Comments

@heathervv
Copy link

Short description

I'm trying to add a submit button beside the geosuggest input to help add functional options for the user. The geosuggest component uses the autoActivateFirstSuggest to always offer a result to the user rather than an error state. When using .selectSuggest() it's searching for exactly what the user typed - and even when typing in a full city (IE Vancouver, BC, Canada) it returns an INVALID_REQUEST

Expected results

I expected that when the geosuggest component has the autoActivateFirstSuggest prop that .selectSuggest() uses it.

Actual results

Instead of .selectSuggest() honouring autoActivateFirstSuggest, I saw that it searches for what's exactly inputted into the input field and returns INVALID_REQUEST

Additional Information

Using version 2.10.0

Here's how my markup looks:

<Geosuggest
    ref={(input) => { this.geoSuggest = input }}
    placeholder="Enter address, city, or postal code"
    onSuggestSelect={this.updateAddress}
    onChange={this.handleAddressChange}
    country="ca"
    autoActivateFirstSuggest
/>

<button className="search-submit" onClick={() => this.geoSuggest.selectSuggest()}>Go</button>

Response from the network call when hitting the button:

/**/_xdc_._o7v3hz && _xdc_._o7v3hz( {
   "html_attributions" : [],
   "status" : "INVALID_REQUEST"
})

Request URL for ref: https://maps.googleapis.com/maps/api/place/js/PlaceService.GetPlaceDetails?2sen-US&8sVancouver%2C%20BC%2C%20Canada&10e3&15s3CBA685F-FB46-4D38-BA6A-982D434DE6A5ab1qrfk3rz4d&17m1&2e1&callback=_xdc_._o7v3hz&key={GOOGLE-API-KEY}&token=95578

One other thing to note, when I remove autoActivateFirstSuggest as a prop, clicking enter on the input field results in the same network response, which is why I'm assuming this is related to there being no results.

If there's another reason why it's responding with INVALID_REQUEST, I couldn't find any documentation around it, so I'd love to be pointed in the direction of more information!

@ro-ka
Copy link
Contributor

ro-ka commented Apr 5, 2019

Thanks for the feedback! It sound reasonable to return the first result then. I’ll open a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants