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 351e63ecd63c5ab68e66879a4272a223390058e2..7c17fae400a0aa39fd773d305278714e74f534f2 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -327,6 +327,7 @@ var SnippetEditor = Widget.extend({ if (this.isDestroyed()) { return; } + this.willDestroyEditors = true; await this.toggleTargetVisibility(!this.$target.hasClass('o_snippet_invisible')); const proms = _.map(this.styles, option => { return option.cleanForSave(); @@ -1139,6 +1140,10 @@ var SnippetEditor = Widget.extend({ * @param {OdooEvent} ev */ _onSnippetOptionVisibilityUpdate: function (ev) { + if (this.willDestroyEditors) { + // Do not update the option visibilities if we are destroying them. + return; + } ev.data.show = this._toggleVisibilityStatus(ev.data.show); }, /** @@ -1574,6 +1579,7 @@ var SnippetsMenu = Widget.extend({ // may be the moment where the public widgets need to be destroyed). this.trigger_up('ready_to_clean_for_save'); + this.willDestroyEditors = true; // Then destroy all snippet editors, making them call their own // "clean for save" methods (and options ones). await this._destroyEditors(); @@ -3403,6 +3409,10 @@ var SnippetsMenu = Widget.extend({ * @param {OdooEvent} ev */ _onSnippetOptionVisibilityUpdate: async function (ev) { + if (this.willDestroyEditors) { + // Do not update the option visibilities if we are destroying them. + return; + } if (!ev.data.show) { await this._activateSnippet(false); }