summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorBenjamin Vray <bvr@odoo.com>2020-11-23 14:46:45 +0000
committerqsm-odoo <qsm@odoo.com>2021-01-27 15:10:51 +0000
commitb7d522e9e7e31ac6bf926aae65e58d9f6cfa8903 (patch)
tree768d89f1311bc648ccccb04c72bfe8bb2ea5c5df /addons/web_editor/static/src
parentedf28efe19bedfe5eb62baf6fa5832a50d18e775 (diff)
[FIX] web_editor: prevent a modal from closing when dropping a snippet
Before this commit, when you dropped a snippet using the move button in a modal. The modal closed after the drop. This commit allows to define an element in which to destroy the editors. Part of https://github.com/odoo/odoo/pull/61998 task-2312878 closes odoo/odoo#61998 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js14
1 files changed, 12 insertions, 2 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 a67f45b3dc0..4e151f29546 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -1521,9 +1521,15 @@ var SnippetsMenu = Widget.extend({
},
/**
* @private
+ * @param {jQuery|null|undefined} [$el]
+ * The DOM element whose inside editors need to be destroyed.
+ * If no element is given, all the editors are destroyed.
*/
- _destroyEditors: async function () {
+ _destroyEditors: async function ($el) {
const proms = _.map(this.snippetEditors, async function (snippetEditor) {
+ if ($el && !$el.has(snippetEditor.$target).length) {
+ return;
+ }
await snippetEditor.cleanForSave();
snippetEditor.destroy();
});
@@ -2291,7 +2297,11 @@ var SnippetsMenu = Widget.extend({
* @param {OdooEvent} ev
*/
_onDragAndDropStop: async function (ev) {
- await this._destroyEditors();
+ const $modal = ev.data.$snippet.closest('.modal');
+ // If the snippet is in a modal, destroy editors only in that modal.
+ // This to prevent the modal from closing because of the cleanForSave
+ // on each editors.
+ await this._destroyEditors($modal.length ? $modal : null);
await this._activateSnippet(ev.data.$snippet);
},
/**