From 86e5ae79544b90cdbaa0fcd616fcaced9087ec0b Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Tue, 18 Oct 2022 14:52:34 +0000 Subject: [PATCH] [FIX] website: fix wrong selector creation in clickOnSnippet tour util Since [1], there would be a traceback due to a wrong DOM selector in the `configurator_tour`. Indeed, completing the configurator will activate the configurator_tour asset which is calling a broken clickOnSnippet tour util to generate an appropriate homepage tour. It would end up with the following selector: `o_website_preview[data-view-xmlid='website.homepage'] iframe #wrapwrap .#wrap > section:nth-child(2)` See the `.#wrap` which is incorrect and make jQuery crash. This is because [1] adapted the tour utils to the new WebsitePreview client action, but the clickOnSnippet function was wrongly changed and could now be generating wrong triggers selector. It was creating invalid selectors as it was concatenating a `.` with the provided string parameter which was basically a class without the `.`, like `s_popup`, but not in all cases. A whole valid selector could also be provided, meaning that concatenating it with a leading `.` would result in incorrect selector. Basically, this commit revert the change made on [1] in `clickOnSnippet` to restore the code of [2] that was preventing the wrong selector creation. [1]: https://github.com/odoo/odoo/commit/99b50d18e220aedf14de806f4bf1b2d35c32de35 [2]: https://github.com/odoo/odoo/commit/e8a5af2e28a4724f86783746706cb59175f086bf opw-3026167 closes odoo/odoo#103651 X-original-commit: 26c4e4a13b642e2856495a8c1f5a36afe3996c02 Signed-off-by: Romain Derie (rde) --- addons/website/static/src/js/tours/tour_utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/tours/tour_utils.js b/addons/website/static/src/js/tours/tour_utils.js index ee35fdf14ef..cf2263fe784 100644 --- a/addons/website/static/src/js/tours/tour_utils.js +++ b/addons/website/static/src/js/tours/tour_utils.js @@ -171,9 +171,9 @@ function clickOnElement(elementName, selector) { * @param {*} position */ function clickOnSnippet(snippet, position = "bottom") { - const snippetClass = snippet.id || snippet; + const trigger = snippet.id ? `#wrapwrap .${snippet.id}` : snippet; return { - trigger: `iframe #wrapwrap .${snippetClass}`, + trigger: `iframe ${trigger}`, extra_trigger: "body.editor_has_snippets", content: Markup(_t("Click on a snippet to access its options menu.")), position: position,