From 0ac7d67c5fa1ba94fdadf8d6563568bdaf28e009 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 6 Feb 2020 17:58:59 +0000 Subject: [PATCH] [FIX] web_editor: fix gallery blocking the editor after image reordering When snippets deeply alter the DOM (e.g. image reordering in gallery), the related option might be destroyed since they are referencing old DOM. If such a case occurred, the destroyed option was still waiting for an option update response by the editor before being considered as finished... which then never occurred and blocked the editor. closes odoo/odoo#44998 X-original-commit: 9eeea4c4107dc15984c475582d5ee58a17cd2568 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 7 +++++++ 1 file changed, 7 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 38b3045040c..11f54264f20 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -2107,6 +2107,13 @@ const SnippetOptionWidget = Widget.extend({ await this._select(previewMode, widget); this.$target.trigger('content_changed'); + // Enabling an option and notifying that the $target has changed + // may destroy the option (if the DOM is altered in such a way the + // option is not attached to it anymore). In that case, we must not + // wait for a response to the option update. + if (this.isDestroyed()) { + return; + } await new Promise(resolve => { // Will update the UI of the correct widgets for all options // related to the same $target/editor if necessary