From aaa0aeb527727c016ee106b7518dfd4c158a8397 Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Wed, 14 Sep 2022 14:17:57 +0000 Subject: [PATCH] [FIX] web_editor: remove old values in the color picker widget previews This [first commit] removes the addition and removal of classes on the color picker preview. So far so good, then this [other commit] puts back the class addition but forgets the removal so the preview of the color picker widget kept the old values when they were `bg-*` which could lead to a bad preview of the selected color. This commit fixes that by removing the old values when a new value is set. Steps to reproduce the bug fixed by this commit: - Go to the website app - Edit a page - Drop a Picture block - Change the background color of the block to bg-black for example - Change again the background color of the block to a custom color => The preview of the custom color is not correct, it is still black. [first commit]: https://github.com/odoo/odoo/commit/212a8bfdd21269b18054200b9e2585e1c95540d6 [other commit]: https://github.com/odoo/odoo/commit/a396f791da94d064d58cce15892e74f45d29b7b7 task-2904507 closes odoo/odoo#101828 X-original-commit: 6da33797798e6112e0dd74a4093f296b6e1b2466 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 2 ++ 1 file changed, 2 insertions(+) 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 8e8d1eda074..0deb551213e 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1476,6 +1476,8 @@ const ColorpickerUserValueWidget = SelectUserValueWidget.extend({ await this._colorPaletteRenderPromise; + const classes = weUtils.computeColorClasses(this.colorPalette.getColorNames()); + this.colorPreviewEl.classList.remove(...classes); this.colorPreviewEl.style.removeProperty('background-color'); this.colorPreviewEl.style.removeProperty('background-image'); const prefix = this.options.dataAttributes.colorPrefix || 'bg';