simple-svelte-autocomplete icon indicating copy to clipboard operation
simple-svelte-autocomplete copied to clipboard

onChange gets triggered on parent component mount

Open ycl924 opened this issue 4 years ago • 2 comments

The onChange function set up in the Autocomplete component gets triggered twice before I even do anything. How to stop that? It should only trigger once the Autocomplete input box has lost focus.

ycl924 avatar Feb 21 '21 11:02 ycl924

Same here. In my case, I have 2 different onChange handle functions on separate Autocomplete components. both functions are triggered when I only change the value on one of the components.

fishdaa avatar Nov 06 '21 12:11 fishdaa

I feel like the problem is somewhere here

https://github.com/pstanoev/simple-svelte-autocomplete/blob/f9d8ada45f9ff208379f772e1df6f6dd42d6a3b5/src/SimpleAutocomplete.svelte#L333-L343

$ statements get triggered on component mount, so onSelectedItemChanged is called, so onChange is called

I have no clue how it could/should be solved because i don't know the source code well enough

DavidBruant avatar Mar 12 '24 11:03 DavidBruant