Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving behaviour #25

Closed
okydk opened this issue Jul 30, 2018 · 11 comments
Closed

Saving behaviour #25

okydk opened this issue Jul 30, 2018 · 11 comments
Labels
feature request New feature requested

Comments

@okydk
Copy link

okydk commented Jul 30, 2018

Love the picker and its simplicity!

Would like the ability to save on change though.

Currently the picker crashes if setColor is called within the onChange event. And there is no way to trigger an event when the picker is closed/hidden, which makes it tricky to achieve the behaviour with the current setup.

@simonwep simonwep added the bug Something isn't working label Jul 30, 2018
@simonwep simonwep changed the title FR: Saving behaviour Saving behaviour Jul 30, 2018
@simonwep
Copy link
Owner

simonwep commented Jul 30, 2018

Thanks :) Really appreciate it!
Okay, onChange is called every time when you changed the color, with setColor you would change it whereby this would be an infinite loop. I'm a little bit confused in which circumstances it would make sense to change the color immediately after every mouse-move which the users performs? What about onSave?

@simonwep simonwep removed the bug Something isn't working label Jul 30, 2018
@jaschaio
Copy link
Contributor

jaschaio commented Aug 6, 2018

Using the internal _saveColor method works for me:

onChange: ( hsva, instance ) => {
    this.Pickr._saveColor();
}

@simonwep
Copy link
Owner

simonwep commented Aug 6, 2018

@jaschaio That's an internal method and not save to use it in this way. This method saves the current color and would result in a horrible performance if you would call it in onChange. Moreover it has nothing to do with color-setting. Only saving, as the name suggests :)

@jaschaio
Copy link
Contributor

jaschaio commented Aug 6, 2018

@simonwep Ok but it works exactly like what I was looking for. As you've asked for the use case: I would actually like to ommit the save button and just set the value of a text input field always to the current value of the color input – similar to this gif:

no-saving

Listening to the onChange event and updating the value of the textInput is currently working for me. Maybe we are missing a Pickr.save() method that could be called from any element or listener without performance issues.

@simonwep
Copy link
Owner

simonwep commented Aug 6, 2018

@jaschaio Ahh, yeah... that makes sense.
Fantastic idea, Will be added :)

@simonwep simonwep added feature request New feature requested in progress labels Aug 6, 2018
@simonwep
Copy link
Owner

simonwep commented Aug 7, 2018

Okay, I've added it in 2ec9036. Simply add comparison: false to your pickr config-object and the button (and preview) get's immediately updated when you select a color :)

@okydk
Copy link
Author

okydk commented Aug 8, 2018

Brilliant! Seems to work. :) Looking forward to have it via npm in 0.1.9.
Is there a way to hide the 'save' button, or should it just be done via CSS?

@simonwep
Copy link
Owner

simonwep commented Aug 8, 2018

Ouch damn, Seems like I missed a component option as I added the save button 😬
I will add this option later today! Will be components.output.save which you can toggle :)

@simonwep
Copy link
Owner

simonwep commented Aug 8, 2018

So, finally :D Now the save-button can be hide with (00564e8):

components: {
    output: {
        save: false
    }
}

Yeah, output as container name is a little bit wrong in this context. It's from the beginning where only output and color modes exists, maybe I will change it in the next major release. Anyway, I think I'll publish 0.1.9 tomorrow or in a few days :)

@okydk
Copy link
Author

okydk commented Aug 9, 2018

🎉

@okydk okydk closed this as completed Aug 9, 2018
joallard added a commit to joallard/pickr that referenced this issue Mar 10, 2020
Motivation: I had a hard time finding the option, and even did a Cmd-F for "save" and couldn't find this ;) Fortunately I could parse through simonwep#25 to find it!
@Jaybagz
Copy link

Jaybagz commented Nov 8, 2021

@simonwep how to hide pickr after clicking save button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature requested
Projects
None yet
Development

No branches or pull requests

4 participants