-
Notifications
You must be signed in to change notification settings - Fork 77
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
Setting the colour programmatically from outside the picker #76
Comments
Oh how did I miss this issue and created #78 instead... Use this instead: |
This works fine for dark colors, but when selecting a light color, the text becomes unreadable. |
I've been having the same problem that @ypanagopoulos has been having. It will update the color, but it won't check if it needs to update to dark/light mode for readability until you click on the color input. |
EDIT: Solved my own problem, see solution below. My current code for changing the color programmatically is just:
And trying to update it so it renders the text color change not just the background color I can run this code:
However, my code calls this function that sets the color as the I added a second parameter to my setColor function that runs on renderCallback. The parameter is a boolean called
I then made the variable default to true and when the colorPicker's renderCallback function runs and calls this, I pass the argument of false so it doesn't recur forever. |
I'm building an app with an eye dropper tool that needs to change the colour stored inside the colour picker, from outside the picker. Here's how I'm setting the colour at the moment (not sure if this is the right way to do it!):
This works, but only after the user has clicked the picker already. If the user hasn't clicked the picker yet, this error occurs:
Uncaught TypeError: Cannot read property '_colorMode' of undefined
This is due to an empty
_$trigger
variable, which seems to contain the DOM element representing the picker. What I'm looking for is a way to initialise the picker before the user clicks it so that this error does not occur.I couldn't figure out how to set the
_$trigger
variable myself as it seems to be encapsulated pretty tight - not that easy to access outside of the picker module.Here is a jsfiddle that demonstrates the problem:
https://jsfiddle.net/4phnsz7x/19/
If you click the link before clicking the picker, you get the error. If you click the picker first, there is no error.
The text was updated successfully, but these errors were encountered: