summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorxO-Tx <mou@odoo.com>2021-05-21 16:09:05 +0000
committerqsm-odoo <qsm@odoo.com>2021-05-27 13:28:46 +0000
commitfd31c9a10f97c92a48d0589a8bbeaf13a641e891 (patch)
tree1d466ddf8c02bda6ec86389cb6d81f141369083f /addons
parentc76d1a0f0210565768c88271625212359720632e (diff)
[FIX] website, web_editor: fix colorpicker preview
Issue: > Set bg color combination for a snippet... > Save > Edit mode > Select the snippet > Open color palette in bg option > Hover a color option > When a color button is left, the preview is cancelled but the color combination class is not applied anymore. In '_computeWidgetState' (for 'selectStyle' method), the right value ('o_cci') is not returned because we get empty "colorNames" (the "colorPalette" is not rendered on start). The goal of this commit is to fix this behaviour by rendering the colorPalette in start for snippet options, this way, the new code won't affect the speed fix added in [1] for 'OPTIONS' tab. [1]: https://github.com/odoo/odoo/pull/65223/commits/ce54c3f21293513673cb1fc6073ada5f0a2b5641 task-2538326 closes odoo/odoo#71174 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js16
-rw-r--r--addons/website/static/src/js/editor/snippets.options.js10
2 files changed, 20 insertions, 6 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 8d5e385408d..b218ea9c5d4 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -1241,12 +1241,16 @@ const ColorpickerUserValueWidget = SelectUserValueWidget.extend({
const _super = this._super.bind(this);
const args = arguments;
- // TODO review in master, this was done in stable to keep the speed fix
- // as stable as possible (to have a reference to a widget even if not a
- // colorPalette widget).
- this.colorPalette = new Widget(this);
- this.colorPalette.getColorNames = () => [];
- await this.colorPalette.appendTo(document.createDocumentFragment());
+ if (this.options.dataAttributes.lazyPalette === 'true') {
+ // TODO review in master, this was done in stable to keep the speed
+ // fix as stable as possible (to have a reference to a widget even
+ // if not a colorPalette widget).
+ this.colorPalette = new Widget(this);
+ this.colorPalette.getColorNames = () => [];
+ await this.colorPalette.appendTo(document.createDocumentFragment());
+ } else {
+ await this._renderColorPalette();
+ }
// Build the select element with a custom span to hold the color preview
this.colorPreviewEl = document.createElement('span');
diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js
index d9204139dad..28354332133 100644
--- a/addons/website/static/src/js/editor/snippets.options.js
+++ b/addons/website/static/src/js/editor/snippets.options.js
@@ -997,6 +997,14 @@ options.registry.OptionsTab = options.Class.extend({
});
return aceEditor;
},
+ /**
+ * @override
+ */
+ async _renderCustomXML(uiFragment) {
+ uiFragment.querySelectorAll('we-colorpicker').forEach(el => {
+ el.dataset.lazyPalette = 'true';
+ });
+ },
});
options.registry.ThemeColors = options.registry.OptionsTab.extend({
@@ -1062,6 +1070,8 @@ options.registry.ThemeColors = options.registry.OptionsTab.extend({
}
uiFragment.appendChild(collapseEl);
}
+
+ await this._super(...arguments);
},
});