diff options
Diffstat (limited to 'addons/web_editor/static/src/js/editor')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.editor.js | 14 |
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); }, /** |
