diff options
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.options.js | 2 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js | 15 |
2 files changed, 14 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 52f1bebb023..7496eb29018 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1320,7 +1320,7 @@ const ColorpickerUserValueWidget = SelectUserValueWidget.extend({ async setValue(color) { await this._super(...arguments); - await this._renderColorPalette(); + this.colorPalette.setSelectedColor(this._value); const classes = weUtils.computeColorClasses(this.colorPalette.getColorNames()); this.colorPreviewEl.classList.remove(...classes); diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js index ff5fa4b0a75..d00abd1ad38 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js @@ -159,6 +159,14 @@ const ColorPaletteWidget = Widget.extend({ getColorNames: function () { return this.colorNames; }, + /** + * Sets the currently selected color + * + * @param {string} color rgb[a] + */ + setSelectedColor: function (color) { + this._selectColor({color: color}); + }, //-------------------------------------------------------------------------- // Private @@ -261,13 +269,16 @@ const ColorPaletteWidget = Widget.extend({ * Set the selectedColor and trigger an event * * @param {Object} color - * @param {string} eventName + * @param {string} [eventName] */ _selectColor: function (colorInfo, eventName) { this.selectedColor = colorInfo.color = this.colorToColorNames[colorInfo.color] || colorInfo.color; - this.trigger_up(eventName, colorInfo); + if (eventName) { + this.trigger_up(eventName, colorInfo); + } this._buildCustomColors(); this._markSelectedColor(); + this.colorPicker.setSelectedColor(colorInfo.color); }, /** * Mark the selected color |
