Minor fixes for reactivity issues and some updates

This commit is contained in:
Dean 2023-01-23 09:06:21 +00:00
parent f53542c45b
commit a9ce6e9cc0
4 changed files with 24 additions and 5 deletions

View File

@ -3,6 +3,9 @@ export default function positionDropdown(
{ anchor, align, maxWidth, useAnchorWidth, showTip } { anchor, align, maxWidth, useAnchorWidth, showTip }
) { ) {
const update = () => { const update = () => {
if (!anchor) {
return
}
const anchorBounds = anchor.getBoundingClientRect() const anchorBounds = anchor.getBoundingClientRect()
const elementBounds = element.getBoundingClientRect() const elementBounds = element.getBoundingClientRect()
let styles = { let styles = {
@ -66,7 +69,9 @@ export default function positionDropdown(
const resizeObserver = new ResizeObserver(entries => { const resizeObserver = new ResizeObserver(entries => {
entries.forEach(update) entries.forEach(update)
}) })
if (anchor) {
resizeObserver.observe(anchor) resizeObserver.observe(anchor)
}
resizeObserver.observe(element) resizeObserver.observe(element)
resizeObserver.observe(document.body) resizeObserver.observe(document.body)

View File

@ -16,6 +16,9 @@
$: tourStepKey = $store.tourStepKey $: tourStepKey = $store.tourStepKey
const initTour = targetKey => { const initTour = targetKey => {
if (!targetKey) {
return
}
tourSteps = [...TOURS[targetKey]] tourSteps = [...TOURS[targetKey]]
tourStepIdx = 0 tourStepIdx = 0
tourStep = { ...tourSteps[tourStepIdx] } tourStep = { ...tourSteps[tourStepIdx] }
@ -24,6 +27,9 @@
$: initTour(tourKey) $: initTour(tourKey)
const updateTourStep = targetStepKey => { const updateTourStep = targetStepKey => {
if (!tourSteps?.length) {
return
}
tourStepIdx = getCurrentStepIdx(tourSteps, targetStepKey) tourStepIdx = getCurrentStepIdx(tourSteps, targetStepKey)
lastStep = tourStepIdx + 1 == tourSteps.length lastStep = tourStepIdx + 1 == tourSteps.length
tourStep = { ...tourSteps[tourStepIdx] } tourStep = { ...tourSteps[tourStepIdx] }
@ -33,6 +39,9 @@
$: updateTourStep(tourStepKey) $: updateTourStep(tourStepKey)
const showPopover = (tourStep, tourNodes, popover) => { const showPopover = (tourStep, tourNodes, popover) => {
if (!tourStep) {
return
}
popoverAnchor = tourNodes[tourStep.id] popoverAnchor = tourNodes[tourStep.id]
popover?.show() popover?.show()
} }

View File

@ -20,7 +20,9 @@
ready = true ready = true
}) })
onDestroy(() => { onDestroy(() => {
if (handler) {
handler.destroy() handler.destroy()
}
}) })
</script> </script>

View File

@ -72,11 +72,14 @@ const getTours = () => {
onboardedAt: new Date().toISOString(), onboardedAt: new Date().toISOString(),
}) })
// Update the cached user
await auth.getSelf()
store.update(state => ({ store.update(state => ({
...state, ...state,
tourNodes: null, tourNodes: undefined,
tourKey: null, tourKey: undefined,
tourKeyStep: null, tourKeyStep: undefined,
onboarding: false, onboarding: false,
})) }))
} }