Handle errors as a part of the instance to avoid extra refreshes

This commit is contained in:
Adria Navarro 2025-01-22 16:18:29 +01:00
parent 2213cd56c4
commit d3b22e461e
2 changed files with 9 additions and 1 deletions

View File

@ -138,7 +138,7 @@
// Derive definition properties which can all be optional, so need to be
// coerced to booleans
$: invalidSettings = $builderStore.componentErrors[instance._id]
$: invalidSettings = instance?._meta?.errors
$: hasChildren = !!definition?.hasChildren
$: showEmptyState = definition?.showEmptyState !== false
$: hasMissingRequiredSettings = missingRequiredSettings?.length > 0

View File

@ -42,6 +42,14 @@ const createScreenStore = () => {
if ($builderStore.layout) {
activeLayout = $builderStore.layout
}
// Attach meta
const errors = $builderStore.componentErrors || {}
const attachComponentMeta = component => {
component._meta = { errors: errors[component._id] || [] }
component._children?.forEach(attachComponentMeta)
}
attachComponentMeta(activeScreen.props)
} else {
// Find the correct screen by matching the current route
screens = $appStore.screens || []