From a9ce6e9cc0189835f0b57ed439226478079f76cb Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 23 Jan 2023 09:06:21 +0000 Subject: [PATCH] Minor fixes for reactivity issues and some updates --- packages/bbui/src/Actions/position_dropdown.js | 7 ++++++- .../src/components/portal/onboarding/TourPopover.svelte | 9 +++++++++ .../src/components/portal/onboarding/TourWrap.svelte | 4 +++- .../builder/src/components/portal/onboarding/tours.js | 9 ++++++--- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/bbui/src/Actions/position_dropdown.js b/packages/bbui/src/Actions/position_dropdown.js index d04159476c..0187b8600c 100644 --- a/packages/bbui/src/Actions/position_dropdown.js +++ b/packages/bbui/src/Actions/position_dropdown.js @@ -3,6 +3,9 @@ export default function positionDropdown( { anchor, align, maxWidth, useAnchorWidth, showTip } ) { const update = () => { + if (!anchor) { + return + } const anchorBounds = anchor.getBoundingClientRect() const elementBounds = element.getBoundingClientRect() let styles = { @@ -66,7 +69,9 @@ export default function positionDropdown( const resizeObserver = new ResizeObserver(entries => { entries.forEach(update) }) - resizeObserver.observe(anchor) + if (anchor) { + resizeObserver.observe(anchor) + } resizeObserver.observe(element) resizeObserver.observe(document.body) diff --git a/packages/builder/src/components/portal/onboarding/TourPopover.svelte b/packages/builder/src/components/portal/onboarding/TourPopover.svelte index 58c29d86d1..ec9a9a999b 100644 --- a/packages/builder/src/components/portal/onboarding/TourPopover.svelte +++ b/packages/builder/src/components/portal/onboarding/TourPopover.svelte @@ -16,6 +16,9 @@ $: tourStepKey = $store.tourStepKey const initTour = targetKey => { + if (!targetKey) { + return + } tourSteps = [...TOURS[targetKey]] tourStepIdx = 0 tourStep = { ...tourSteps[tourStepIdx] } @@ -24,6 +27,9 @@ $: initTour(tourKey) const updateTourStep = targetStepKey => { + if (!tourSteps?.length) { + return + } tourStepIdx = getCurrentStepIdx(tourSteps, targetStepKey) lastStep = tourStepIdx + 1 == tourSteps.length tourStep = { ...tourSteps[tourStepIdx] } @@ -33,6 +39,9 @@ $: updateTourStep(tourStepKey) const showPopover = (tourStep, tourNodes, popover) => { + if (!tourStep) { + return + } popoverAnchor = tourNodes[tourStep.id] popover?.show() } diff --git a/packages/builder/src/components/portal/onboarding/TourWrap.svelte b/packages/builder/src/components/portal/onboarding/TourWrap.svelte index 5761247ba3..1be149f7fa 100644 --- a/packages/builder/src/components/portal/onboarding/TourWrap.svelte +++ b/packages/builder/src/components/portal/onboarding/TourWrap.svelte @@ -20,7 +20,9 @@ ready = true }) onDestroy(() => { - handler.destroy() + if (handler) { + handler.destroy() + } }) diff --git a/packages/builder/src/components/portal/onboarding/tours.js b/packages/builder/src/components/portal/onboarding/tours.js index 6477dc0c96..d483a5af8b 100644 --- a/packages/builder/src/components/portal/onboarding/tours.js +++ b/packages/builder/src/components/portal/onboarding/tours.js @@ -72,11 +72,14 @@ const getTours = () => { onboardedAt: new Date().toISOString(), }) + // Update the cached user + await auth.getSelf() + store.update(state => ({ ...state, - tourNodes: null, - tourKey: null, - tourKeyStep: null, + tourNodes: undefined, + tourKey: undefined, + tourKeyStep: undefined, onboarding: false, })) }