cedricdelpoux / react-google-places-suggest

React component to select geolocated suggestion from Google Maps Places API
https://cedricdelpoux.github.io/react-google-places-suggest/
MIT License
86 stars 44 forks source link

Add e.preventDefault for e.key === "Enter" in handleKeyDown-Method #58

Closed dist0erbed closed 4 years ago

dist0erbed commented 4 years ago

First of all, thank you for your work, the component is a great help in our project :).

There is just one little issue that is bothering us: We are using the component in a search form, for getting real addresses.

The problem is, if you use the keyboard to select a place from the suggest dropdown and hit the enter key the wrapping form got submitted and triggers an error because the response from Google isn't ready.

The problem could be solved if you add a e.preventDefault if the enter key is hit in your handleKeyDown-Method.

If I'm missing something there, your help is highly appreciated.

cedricdelpoux commented 4 years ago

Thank you for reporting this. Could you make a PR to fix the problem? It would be very helpfull.