Improve performance of multistep form block

This commit is contained in:
Andrew Kingston 2024-03-20 15:46:07 +00:00
parent 80cc83d2f0
commit fdde7f8895
1 changed files with 6 additions and 8 deletions

View File

@ -26,9 +26,11 @@
let schema
$: id = $component.id
$: selected = $component.selected
$: fetchSchema(dataSource)
$: enrichedSteps = enrichSteps(steps, schema, $component.id, $currentStep)
$: updateCurrentStep(enrichedSteps, $builderStore, $component)
$: updateCurrentStep(enrichedSteps, $builderStore, id, selected)
$: enrichedSteps = enrichSteps(steps, schema, id, $currentStep)
// Provide additional data context for live binding eval
export const getAdditionalDataContext = () => {
@ -40,16 +42,12 @@
}
}
const updateCurrentStep = (steps, builderStore, component) => {
const updateCurrentStep = (steps, builderStore, id, selected) => {
const { componentId, step } = builderStore.metadata || {}
// 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 (
!component.selected ||
!builderStore.inBuilder ||
componentId !== component.id
) {
if (!selected || !builderStore.inBuilder || componentId !== id) {
return
}