react-places-autocomplete icon indicating copy to clipboard operation
react-places-autocomplete copied to clipboard

onChange value undefined

Open tilersmyth opened this issue 7 years ago • 8 comments
trafficstars

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.

tilersmyth avatar Jul 03 '18 02:07 tilersmyth

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

SmirnovW avatar Sep 03 '18 17:09 SmirnovW

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...

tilersmyth avatar Sep 04 '18 14:09 tilersmyth

@tilersmyth Thank you for the feedback!

SmirnovW avatar Sep 05 '18 19:09 SmirnovW

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.

griffith-icp avatar Mar 23 '19 17:03 griffith-icp

@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

tilersmyth avatar Mar 23 '19 19:03 tilersmyth

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)

griffith-icp avatar Mar 23 '19 19:03 griffith-icp

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

ikorason avatar May 17 '19 16:05 ikorason

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

rcabre95 avatar Aug 16 '21 21:08 rcabre95