diff --git a/addons/web_tour/static/src/tour_service/tour_service.js b/addons/web_tour/static/src/tour_service/tour_service.js index 5a0dcc9175f..ef2c1c0fe1d 100644 --- a/addons/web_tour/static/src/tour_service/tour_service.js +++ b/addons/web_tour/static/src/tour_service/tour_service.js @@ -292,6 +292,24 @@ export const tourService = { observer.observe(macroEngine.target, { childList: true, subtree: true }); } + /** + * Register shadow roots that must be observed by the tour to + * the macro engine. + * + * @param {Tour} tour + */ + function setupShadowObservers(tour) { + const shadowDOMs = tour.steps.reduce((acc, step) => { + if (step.shadow_dom) { + acc.add(step.shadow_dom); + } + return acc; + }, new Set()); + if (shadowDOMs.size > 0) { + observeShadows(shadowDOMs); + } + } + /** * Disable transition before starting an "auto" tour. * @param {Macro} macro @@ -338,15 +356,7 @@ export const tourService = { } }); if (!willUnload) { - const shadow_doms = tour.steps.reduce((acc, step) => { - if (step.shadow_dom) { - acc.add(step.shadow_dom); - } - return acc; - }, new Set()); - if (shadow_doms.size > 0) { - observeShadows(shadow_doms); - } + setupShadowObservers(tour); pointer.start(); activateMacro(macro, options.mode); } @@ -371,6 +381,7 @@ export const tourService = { keepWatchBrowser, showPointerDuration, }); + setupShadowObservers(tour); pointer.start(); activateMacro(macro, mode); }