hibiken / react-places-autocomplete

React component for Google Maps Places Autocomplete
https://hibiken.github.io/react-places-autocomplete/
MIT License
1.38k stars 388 forks source link

onChange value undefined #219

Open tilersmyth opened 6 years ago

tilersmyth commented 6 years ago

Do you want to request a feature or report a bug? featurish What is the current behavior? onChange assumes event as variable If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. n/a What is the expected behavior? Hoping onChange can accept value Which versions of ReactPlacesAutocomplete, and which browser / OS are affected by this issue?

@hibiken - I am hoping to use this project with the select component from Ant Design. That component's onChange returns the input's value by default (as opposed to the input event). Just to get it working, I went into PlacesAutocomplete.js and added the below code inside the handleInputChange function (line 225):

var value = event.target ? event.target.value : event;

Is there an intended method to handle this scenario in the current project or not at this time?

Thanks for the help/insight.

SmirnovW commented 6 years ago

@tilersmyth Hi! Did you find any solution to getting the event without changing the react-places-autocomplete?

tilersmyth commented 6 years ago

hey @SmirnovW , I ended up bailing on react-places-autocomplete. creating my own solution (while using this project as a reference) turned out to be easier than I thought it would be...

SmirnovW commented 6 years ago

@tilersmyth Thank you for the feedback!

griffith-icp commented 5 years ago

Hi @tilersmyth , can you share a link to your project? I'm facing a similar issue where I need the event thrown by the input element.

tilersmyth commented 5 years ago

@griffith-icp

I was looking for an autocomplete solution in a setup wizard. My memory is a little foggy on the specifics but you can probably deduce what I did by looking here:

https://github.com/tilersmyth/plug-n-rent/tree/master/packages/client/src/modules/admin/wizard/controller/step2

griffith-icp commented 5 years ago

Yeah thanks @tilersmyth . I found a way out. I plan on cloning this repo, fix a few bugs and host it on npm. Because it's really don't know why the event object wasn't being bubbled up. (I only had to change a few lines in the library)

ikorason commented 5 years ago

I found a work around

<Select {...getInputProps({ onSearch: value => getInputProps().onChange(event = { target: { value } }) })} />

don't know if its a good solution but its working

rcabre95 commented 3 years ago

I'm having the same issue. Not quite sure how to implement these work arounds. Any fixes yet?