From 42a424db20eaf51f3afc11cefeb0c1f9afcfe66d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 9 Jun 2020 08:29:19 +0000 Subject: [PATCH] [FIX] website: only open s_popup snippet once (outside of editor) When the snippet was configured to be opened "on exit", it was opened on every screen exit until the page was reloaded/left. Part of https://github.com/odoo/odoo/pull/52663 closes odoo/odoo#52686 X-original-commit: e07a25c40dc48ff36150f5a10461d95a86e95804 Signed-off-by: Quentin Smetz (qsm) --- addons/website/static/src/snippets/s_popup/000.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/snippets/s_popup/000.js b/addons/website/static/src/snippets/s_popup/000.js index 16820dcc988..a16b711b290 100644 --- a/addons/website/static/src/snippets/s_popup/000.js +++ b/addons/website/static/src/snippets/s_popup/000.js @@ -15,7 +15,8 @@ const PopupWidget = publicWidget.Widget.extend({ * @override */ start: function () { - if (!utils.get_cookie(this.$el.attr('id'))) { + this._popupAlreadyShown = !!utils.get_cookie(this.$el.attr('id')); + if (!this._popupAlreadyShown) { this._bindPopup(); } return this._super(...arguments); @@ -66,6 +67,9 @@ const PopupWidget = publicWidget.Widget.extend({ * @private */ _showPopup: function () { + if (this._popupAlreadyShown) { + return; + } this.$target.find('.s_popup_main').removeClass('d-none'); }, @@ -79,6 +83,7 @@ const PopupWidget = publicWidget.Widget.extend({ _onCloseClick: function () { const nbDays = this.$el.find('.s_popup_main').data('consentsDuration'); utils.set_cookie(this.$el.attr('id'), true, nbDays * 24 * 60 * 60); + this._popupAlreadyShown = true; this._hidePopup(); }, });