From c276545de7a4e575c30fc70151e4b0c234f90c39 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 20 Sep 2021 09:33:06 +0000 Subject: [PATCH] [FIX] web_editor: properly await all async parts for onRemove/onClone Even though onRemove and onClone cannot be async themselves (yet?), it is called via a trigger_up of `call_for_each_child_snippet` so that each part of the snippet being removed / cloned has their onRemove / onClone called. Doing that way, some SnippetEditor instances may have to be created and it can be an async operation... the problem is that our code was only awaiting the first of those instanciations instead of all of them. closes odoo/odoo#76881 X-original-commit: ea2a40afb96147e83c897a0376e187d8c957e66a Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 0f9adacdfe4..7f51ee7749d 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -455,8 +455,8 @@ var SnippetEditor = Widget.extend({ for (var i in editor.styles) { editor.styles[i].onRemove(); } - resolve(); }, + onSuccess: resolve, }); }); @@ -669,8 +669,8 @@ var SnippetEditor = Widget.extend({ isCurrent: ($snippet.is($clone)), }); } - resolve(); }, + onSuccess: resolve, }); }); this.trigger_up('snippet_cloned', {$target: $clone, $origin: this.$target}); @@ -2656,7 +2656,8 @@ var SnippetsMenu = Widget.extend({ * @param {OdooEvent} ev */ _onCallForEachChildSnippet: function (ev) { - this._callForEachChildSnippet(ev.data.$snippet, ev.data.callback); + this._callForEachChildSnippet(ev.data.$snippet, ev.data.callback) + .then(() => ev.data.onSuccess()); }, /** * Called when the overlay dimensions/positions should be recomputed.