[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) <bvr@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Benjamin Vray
2023-02-27 16:03:41 +01:00
parent 0fa9b07d8f
commit 6d5586801a
2 changed files with 9 additions and 4 deletions
@@ -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');
}
},
//--------------------------------------------------------------------------
@@ -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');
});
},