From 3a02d3970d3f0fbdaba4c68a28fda169b2062dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Geelen=20=28sge=29?= Date: Tue, 16 Nov 2021 10:05:48 +0000 Subject: [PATCH] [FIX] web_editor: remove warning on save Pop-up warning was appearing when saving website pages. task-2666177 closes odoo/odoo#79842 X-original-commit: 2b35640d9e1fb7f037eee1983a19876879936d67 Signed-off-by: David Monjoie (dmo) Signed-off-by: Antoine Guenet --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 9c7eb097845..d4a0b9bfd1e 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -212,11 +212,12 @@ const Wysiwyg = Widget.extend({ }, options)); await this._insertSnippetMenu(); - window.addEventListener('beforeunload', (event) => { + this._onBeforeUnload = (event) => { if (this.isDirty()) { event.returnValue = _t('This document is not saved!'); } - }); + }; + window.addEventListener('beforeunload', this._onBeforeUnload); } if (this.options.getContentEditableAreas) { $(this.options.getContentEditableAreas()).find('*').off('mousedown mouseup click'); @@ -676,7 +677,7 @@ const Wysiwyg = Widget.extend({ await this._saveViewBlocks(); this.trigger_up('edition_was_stopped'); - window.onbeforeunload = null; + window.removeEventListener('beforeunload', this._onBeforeUnload); if (reload) { window.location.reload(); }