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 Placeholder from "../Placeholder.svelte"
export let step
export let step = 1
const { styleable, builderStore } = getContext("sdk")
const component = getContext("component")
@ -14,16 +14,15 @@
$: formState = formContext?.formState
$: 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) {
console.log($builderStore.selectedPath)
console.log($component.id)
if ($builderStore.selectedComponentPath?.includes($component.id)) {
console.log("selecting " + step)
formContext.formApi.setStep(step)
}
if (
formContext &&
$builderStore.inBuilder &&
$builderStore.selectedComponentPath?.includes($component.id) &&
$formState?.currentStep !== step
) {
formContext.formApi.setStep(step)
}
}
</script>