[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) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2020-02-10 14:28:34 +00:00
parent 32a8b4dce3
commit 0ac7d67c5f
@@ -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