Only show the selected step if not already selected

This commit is contained in:
Andrew Kingston 2021-08-19 14:56:56 +01:00
parent a5778f9dbc
commit 3020b59d86
1 changed files with 9 additions and 10 deletions

View File

@ -2,7 +2,7 @@
import { getContext, setContext } from "svelte" import { getContext, setContext } from "svelte"
import Placeholder from "../Placeholder.svelte" import Placeholder from "../Placeholder.svelte"
export let step export let step = 1
const { styleable, builderStore } = getContext("sdk") const { styleable, builderStore } = getContext("sdk")
const component = getContext("component") const component = getContext("component")
@ -14,18 +14,17 @@
$: formState = formContext?.formState $: formState = formContext?.formState
$: currentStep = $formState?.currentStep $: currentStep = $formState?.currentStep
// If in the builder preview, show this step if it is selected // If in the builder preview, show this step if a child is selected
$: { $: {
if (step && formContext && $builderStore.inBuilder) { if (
console.log($builderStore.selectedPath) formContext &&
console.log($component.id) $builderStore.inBuilder &&
$builderStore.selectedComponentPath?.includes($component.id) &&
if ($builderStore.selectedComponentPath?.includes($component.id)) { $formState?.currentStep !== step
console.log("selecting " + step) ) {
formContext.formApi.setStep(step) formContext.formApi.setStep(step)
} }
} }
}
</script> </script>
{#if !formContext} {#if !formContext}