diff --git a/packages/client/src/components/app/blocks/MultiStepFormblock.svelte b/packages/client/src/components/app/blocks/MultiStepFormblock.svelte index f47655882d..5cb3640355 100644 --- a/packages/client/src/components/app/blocks/MultiStepFormblock.svelte +++ b/packages/client/src/components/app/blocks/MultiStepFormblock.svelte @@ -28,9 +28,11 @@ $: id = $component.id $: selected = $component.selected + $: inBuilder = $builderStore.inBuilder + $: builderStep = $builderStore.metadata?.step $: fetchSchema(dataSource) - $: updateCurrentStep(enrichedSteps, $builderStore, id, selected) - $: enrichedSteps = enrichSteps(steps, schema, id, $currentStep) + $: enrichedSteps = enrichSteps(steps, schema, id) + $: updateCurrentStep(enrichedSteps, selected, inBuilder, builderStep) // Provide additional data context for live binding eval export const getAdditionalDataContext = () => { @@ -42,17 +44,15 @@ } } - const updateCurrentStep = (steps, builderStore, id, selected) => { - const { componentId, step } = builderStore.metadata || {} - + const updateCurrentStep = (steps, selected, inBuilder, builderStep) => { // If we aren't in the builder or aren't selected then don't update the step // context at all, allowing the normal form to take control. - if (!selected || !builderStore.inBuilder || componentId !== id) { + if (!selected || !inBuilder) { return } // Ensure we have a valid step selected - let newStep = Math.min(step || 0, steps.length - 1) + let newStep = Math.min(builderStep || 0, steps.length - 1) // Sanity check newStep = Math.max(newStep, 0) @@ -61,7 +61,7 @@ currentStep.set(newStep + 1) } - const fetchSchema = async () => { + const fetchSchema = async dataSource => { schema = (await fetchDatasourceSchema(dataSource)) || {} }