From 8a8d4e7c59391a3d69214bcf4b37adc078c69e36 Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Wed, 10 May 2023 07:51:30 +0000 Subject: [PATCH] [FIX] website: reorder selectors used for switching cookie banner layout The cookie policy banner template includes nested selectors, such as o_cookies_bar_text_policy within o_cookies_bar_text_secondary. The process for switching the banner layout involves copying selectors based on the order defined in CookiesBar::selectLayout()::selectorsToKeep. However, a bug caused o_cookies_bar_text_policy to be copied before o_cookies_bar_text_secondary, resulting in its content being overridden by its parent content. The fix involves reordering the selectors so that o_cookies_bar_text_secondary is copied before o_cookies_bar_text_policy. opw-3302511 closes odoo/odoo#121324 X-original-commit: 720ae005bce261ce3b9e32dc8ade1f1d97f1aee1 Signed-off-by: Romain Derie (rde) --- addons/website/static/src/js/editor/snippets.options.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 6364af83048..9a8d4a2d59c 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -2779,13 +2779,20 @@ options.registry.CookiesBar = options.registry.SnippetPopup.extend({ })); const $content = this.$target.find('.modal-content'); + + // The order of selectors is significant since certain selectors may be + // nested within others, and we want to preserve the nested ones. + // For instance, in the case of '.o_cookies_bar_text_policy' nested + // inside '.o_cookies_bar_text_secondary', the parent selector should be + // copied first, followed by the child selector to ensure that the + // content of the nested selector is not overwritten. const selectorsToKeep = [ '.o_cookies_bar_text_button', '.o_cookies_bar_text_button_essential', - '.o_cookies_bar_text_policy', '.o_cookies_bar_text_title', '.o_cookies_bar_text_primary', '.o_cookies_bar_text_secondary', + '.o_cookies_bar_text_policy' ]; if (this.$savedSelectors === undefined) {