From 6d5586801a0f06a532d124c7fdeec99740b0db8d Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Tue, 31 Jan 2023 09:20:32 +0000 Subject: [PATCH] [FIX] website: fix popup that closes when editing Before this commit, in some instances when editing text in a popup, the popup would close. The issue was introduced by this commit [1]. A 'd-none' class is since added on the 's_popup' section when the modal closes but when the widget starts with the modal already open (e.g. during a widget refresh), the 'd-none' class is not removed from the section. Steps to reproduce: - Edit a page. - Drop a popup. - Select a word or a sentence and delete it or press "Enter" to create a new paragraph. - Bug => the popup closes. [1]: https://github.com/odoo/odoo/commit/cfd53b8fae3ad9f677df49a03fe6d2945dbb5da2 task-3102275 closes odoo/odoo#113746 X-original-commit: fb2495d3b87223be65f98583056a070439a7df7e Signed-off-by: Vray Benjamin (bvr) Signed-off-by: Quentin Smetz (qsm) --- addons/website/static/src/snippets/s_popup/000.js | 10 ++++++---- addons/website/static/src/snippets/s_popup/options.js | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/website/static/src/snippets/s_popup/000.js b/addons/website/static/src/snippets/s_popup/000.js index d6f559fb331..00dd7ad9124 100644 --- a/addons/website/static/src/snippets/s_popup/000.js +++ b/addons/website/static/src/snippets/s_popup/000.js @@ -31,10 +31,12 @@ const SharedPopupWidget = publicWidget.Widget.extend({ destroy() { this._super(...arguments); - // Popup are always closed when entering/leaving edit mode (see - // PopupWidget), this allows to make sure the class is sync on the - // .s_popup parent after that moment too. - this.el.classList.add('d-none'); + // Popup are always closed when entering edit mode (see PopupWidget), + // this allows to make sure the class is sync on the .s_popup parent + // after that moment too. + if (!this.editableMode) { + this.el.classList.add('d-none'); + } }, //-------------------------------------------------------------------------- diff --git a/addons/website/static/src/snippets/s_popup/options.js b/addons/website/static/src/snippets/s_popup/options.js index e73ab7d3e82..867de61bedc 100644 --- a/addons/website/static/src/snippets/s_popup/options.js +++ b/addons/website/static/src/snippets/s_popup/options.js @@ -83,6 +83,9 @@ options.registry.SnippetPopup = options.Class.extend({ clearTimeout(timeoutID); resolve(); }); + // The following line is in charge of hiding .s_popup at the same + // time the modal is closed when the page is saved in edit mode. + this.$target[0].closest('.s_popup').classList.add('d-none'); this.$bsTarget.modal('hide'); }); },