summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2020-08-06 16:13:56 +0000
committerqsm-odoo <qsm@odoo.com>2020-08-07 08:52:19 +0000
commit201e10b338c8e50d7dd7d226676797eff6c26199 (patch)
tree8547518e8b026ef204618d46f858d36f9a187781 /addons/web_editor/static/src/js
parent315ba1cfeb737c378ee6828cc6f612f1ab91fa71 (diff)
[FIX] web_editor: remove useless snippet preview notification
Before this commit, the 'snippet_option_update' event was triggered whether or not it was a preview update. In the preview update case, nothing was done, ever. This commit removes the preview notification. If it ever becomes useful, it can be restored at that moment. This commit actually solves a bug introduced by [1]: that snippet update notification is now triggered after a setTimeout delay to allow events to bubble before the UI update it will trigger (in non preview mode). The side effect this had was that, between each preview, the execution chain was deferred of a setTimeout delay between each step (even though previews do not update the UI). This was enough to allow for a paint refresh. So before this commit, if option C was selected, then the user hovered option A then option B, the option C was visually re-enabled between A and B. This won't be the case anymore after this commit. Long story short: restore no-flickering when previewing options. [1]: https://github.com/odoo/odoo/commit/2616c8950fd615561e720660bcc39e018f4061e4 Part of https://github.com/odoo/odoo/pull/55588 closes odoo/odoo#55588 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src/js')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js5
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js17
2 files changed, 5 insertions, 17 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js
index de3bd9e9ca8..ee375c50b71 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -760,11 +760,6 @@ var SnippetEditor = Widget.extend({
* @param {OdooEvent} ev
*/
_onSnippetOptionUpdate: async function (ev) {
- if (ev.data.previewMode) {
- ev.data.onSuccess();
- return;
- }
-
const proms1 = Object.keys(this.styles).map(key => {
return this.styles[key].updateUI({
noVisibility: true,
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 ce0d9b193c1..1c78a420dd1 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -2464,12 +2464,14 @@ const SnippetOptionWidget = Widget.extend({
// Call widget option methods and update $target
await this._select(previewMode, widget);
+ if (previewMode) {
+ return;
+ }
await new Promise(resolve => setTimeout(() => {
// Will update the UI of the correct widgets for all options
- // related to the same $target/editor if necessary
+ // related to the same $target/editor
this.trigger_up('snippet_option_update', {
- previewMode: previewMode,
onSuccess: () => resolve(),
});
// Set timeout needed so that the user event which triggered the
@@ -3210,16 +3212,7 @@ registry.BackgroundImage = SnippetOptionWidget.extend({
this.$target.removeClass('oe_img_bg');
}
- if (previewMode === 'reset') {
- return new Promise(resolve => {
- // Will update the UI of the correct widgets for all options
- // related to the same $target/editor
- this.trigger_up('snippet_option_update', {
- previewMode: 'reset',
- onSuccess: () => resolve(),
- });
- });
- } else {
+ if (previewMode !== 'reset') {
removeOnImageChangeAttrs.forEach(attr => delete this.$target[0].dataset[attr]);
this.$target.trigger('background_changed', [previewMode]);
}