From 19d7c94a2287daf27c73dae29dec2aafbacb5b0c Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 13 Mar 2023 13:17:26 +0000 Subject: [PATCH 1/2] Made tour node registration a bit more forgiving when waiting for tour details to initialise --- .../portal/onboarding/TourWrap.svelte | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/components/portal/onboarding/TourWrap.svelte b/packages/builder/src/components/portal/onboarding/TourWrap.svelte index 2fff8507c5..fbe81d231d 100644 --- a/packages/builder/src/components/portal/onboarding/TourWrap.svelte +++ b/packages/builder/src/components/portal/onboarding/TourWrap.svelte @@ -8,18 +8,26 @@ let currentTourStep let ready = false + let registered = false let handler + const registerTourNode = (tourKey, stepKey) => { + if (ready && !registered && tourKey) { + currentTourStep = TOURS[tourKey].find(step => step.id === stepKey) + if (!currentTourStep) { + console.log("Could not find tour step : ", stepKey) + return + } + const elem = document.querySelector(currentTourStep.query) + handler = tourHandler(elem, stepKey) + registered = true + } + } + + $: tourKeyWatch = $store.tourKey + $: registerTourNode(tourKeyWatch, tourStepKey, ready) + onMount(() => { - if (!$store.tourKey) return - - currentTourStep = TOURS[$store.tourKey].find( - step => step.id === tourStepKey - ) - if (!currentTourStep) return - - const elem = document.querySelector(currentTourStep.query) - handler = tourHandler(elem, tourStepKey) ready = true }) onDestroy(() => { From 567b9418a3bbff5eb13fab621ef681d373206272 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 13 Mar 2023 14:39:36 +0000 Subject: [PATCH 2/2] Made the popover logic more responsive to changes in the tour state. --- .../portal/onboarding/TourPopover.svelte | 16 ++++------------ .../components/portal/onboarding/TourWrap.svelte | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/portal/onboarding/TourPopover.svelte b/packages/builder/src/components/portal/onboarding/TourPopover.svelte index 37ed0c6350..68e2e68a49 100644 --- a/packages/builder/src/components/portal/onboarding/TourPopover.svelte +++ b/packages/builder/src/components/portal/onboarding/TourPopover.svelte @@ -15,20 +15,12 @@ $: tourKey = $store.tourKey $: tourStepKey = $store.tourStepKey - const initTour = targetKey => { - if (!targetKey) { + const updateTourStep = (targetStepKey, tourKey) => { + if (!tourKey) { return } - tourSteps = [...TOURS[targetKey]] - tourStepIdx = 0 - tourStep = { ...tourSteps[tourStepIdx] } - } - - $: initTour(tourKey) - - const updateTourStep = targetStepKey => { if (!tourSteps?.length) { - return + tourSteps = [...TOURS[tourKey]] } tourStepIdx = getCurrentStepIdx(tourSteps, targetStepKey) lastStep = tourStepIdx + 1 == tourSteps.length @@ -36,7 +28,7 @@ tourStep.onLoad() } - $: updateTourStep(tourStepKey) + $: updateTourStep(tourStepKey, tourKey) const showPopover = (tourStep, tourNodes, popover) => { if (!tourStep) { diff --git a/packages/builder/src/components/portal/onboarding/TourWrap.svelte b/packages/builder/src/components/portal/onboarding/TourWrap.svelte index fbe81d231d..fd47d7b48e 100644 --- a/packages/builder/src/components/portal/onboarding/TourWrap.svelte +++ b/packages/builder/src/components/portal/onboarding/TourWrap.svelte @@ -15,7 +15,6 @@ if (ready && !registered && tourKey) { currentTourStep = TOURS[tourKey].find(step => step.id === stepKey) if (!currentTourStep) { - console.log("Could not find tour step : ", stepKey) return } const elem = document.querySelector(currentTourStep.query) @@ -30,6 +29,7 @@ onMount(() => { ready = true }) + onDestroy(() => { if (handler) { handler.destroy()