bgrins / spectrum

The No Hassle JavaScript Colorpicker
https://bgrins.github.io/spectrum/
MIT License
2.32k stars 588 forks source link

change firing twice on paste #397

Closed raystrach closed 8 years ago

raystrach commented 8 years ago

when you paste a color into the selection field the bound element fires two change events. this happens whether or not you hide the palette there and then or if you expect the user to select choose. we have some custom code running on change and no matter which way we did it (we tried about 10 ways inside spectrum and about the same for outside spectrum) it always produced the same or similar result. the event always fired twice.

it appears that change is fired on paste, and change was also fired on hide.

although slightly off topic with this bug report, it occurred to us that it would be useful in our case to have a choose event, which means we could run our custom code then. we tried running it on change and also hide but still came up against the problem above no matter how we structured the code. cheers raymond s

bgrins commented 8 years ago

I think this might be the same issue that's faced in palettes (#269) and desired change is outlined in https://github.com/bgrins/spectrum/issues/250#issuecomment-66397975.

I wonder if removing the 'true' args in updateOriginalInput for the text input would cause any fallout / compat issues. It might be a safer place to start as compared to the palette.

@raystrach on a semi-unrelated point. I'm curious, what do you think about removing the immediate change that happens when a paste happens and requiring the user to press 'enter' or blur the field?

raystrach commented 8 years ago

@bgrins thanks for your response. (and thanks for a great color picker!)

it is possible that the two problems are related

i do think removing this event is better, as it gives a little more control over user input from the developer side.

generally, from a stand alone perspective, having the change on paste is a good thing as it speeds up the process, however when integrating into other applications it is not so good.

in the online website editing program we are developing, we create a stored custom color pallette for the website in question. when this is done, we almost always will paste a value in, then we also do other processing at the time. having more control over this will be very useful.

thanks for the good work.

bgrins commented 8 years ago

OK, filed #406 to remove this event. Not sure if I'll get to it soon but I think it's the right behavior

raystrach commented 8 years ago

thanks brian

when we get it into production over the next couple of months we will be

happy to provide a small annual contribution

cheers

rs

SMART SERVICE SYSTEMS - DEVELOPERS OF SMARTSPACE - WWW.SMARTSPACEHQ.COM [3] support@smartspacehq.com | Ph: 07 3102 5430 | SOS: 0411 757732 | Follow us on Twitter @smartspacehq [4]

On 21/03/2016 11:26, Brian Grinstead wrote:

OK, filed #406 [1] to remove this event. Not sure if I'll get to it soon but I think it's the right behavior

You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub [2]

Links:

[1] https://github.com/bgrins/spectrum/issues/406 [2] https://github.com/bgrins/spectrum/issues/397#issuecomment-199078809 [3] http://www.smartspacehq.com [4] https://twitter.com/smartspacehq