-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUG] When cancel Colorpicker, it set wrong value for component #2683
Comments
Hi @artf, // InputColor.js
/**
* Set value to the model
* @param {string} val
* @param {Object} opts
*/
setValue(val, opts = {}) {
const model = this.model;
const def = model.get('defaults');
const value = !isUndefined(val) ? val : !isUndefined(def) ? def : '';
const inputEl = this.getInputEl();
const colorEl = this.getColorEl();
const valueClr = value != 'none' ? value : '';
inputEl.value = value;
colorEl.get(0).style.backgroundColor = valueClr;
// This prevents from adding multiple thumbs in spectrum
if (opts.fromTarget || (opts.fromInput && !opts.avoidStore)) { // when input changed, update value in spectrum
colorEl.spectrum('set', valueClr);
this.noneColor = value == 'none';
}
}, What do you think about this? If it's ok, I could submit a PR. Thank you. |
I found out that this bug also happen if you change the input with any value, then immediately open colorpick then cancel it by clicking outside (not canvas). |
Update color picker value when user changes value from input. Fix #2683
Are you using the latest release (older versions are NOT supported)?
Yes.
Are you facing the bug with your local copy of GrapesJS or with the current demo?
Both of them.
Steps to reproduce:
What is the expected behavior?
Background color should keep remain.
What happens instead?
Background color change to previous color or #000000.
Screencast
The text was updated successfully, but these errors were encountered: