From 29dff6f1a841b6c507b06e5262a995c51d620153 Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Tue, 8 Nov 2022 15:17:49 +0000 Subject: [PATCH] [FIX] website: enable the "all pages" option of the popup snippet This commit enables the use of the option "All pages" when using a popup snippet. Steps to reproduce the bug: - Drag & drop a popup snippet. - On its option in the right panel, there is "Show On" set by default to "This page". - Try to modify this option and select "All pages". Bug observed: The "All pages" option can not be selected and the "Show On" stays on "This page". This commit has been done because since the version 16.0, the footer is on an iframe [1]. Because of that, the program does not have a direct access to the footer. This is why it is needed to first access the top-level document before using the querySelector. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b task-2983822 closes odoo/odoo#107236 X-original-commit: f469385dcfcbd9290c3522422f9e10600bb60b76 Signed-off-by: Quentin Smetz (qsm) --- addons/website/static/src/snippets/s_popup/options.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/snippets/s_popup/options.js b/addons/website/static/src/snippets/s_popup/options.js index 4e48b94b4c2..eff496375b8 100644 --- a/addons/website/static/src/snippets/s_popup/options.js +++ b/addons/website/static/src/snippets/s_popup/options.js @@ -91,8 +91,10 @@ options.registry.SnippetPopup = options.Class.extend({ * @see this.selectClass for parameters */ moveBlock: function (previewMode, widgetValue, params) { - const $container = $(widgetValue === 'moveToFooter' ? 'footer' : 'main'); - this.$target.closest('.s_popup').prependTo($container.find('.oe_structure:o_editable').first()); + const containerEl = this.$target[0].ownerDocument.querySelector(widgetValue === 'moveToFooter' ? 'footer' : 'main'); + const whereEl = $(containerEl).find('.oe_structure:o_editable')[0]; + const popupEl = this.$target[0].closest('.s_popup'); + whereEl.prepend(popupEl); }, /** * @see this.selectClass for parameters