Fix issue with svelte reactive statements not being sufficiently 'reactive' in core form field in client lib by replacing with manual store subscription

This commit is contained in:
Andrew Kingston 2021-08-23 15:13:41 +01:00
parent 796dc24b06
commit 3fc345a8fe
1 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<script> <script>
import Placeholder from "../Placeholder.svelte" import Placeholder from "../Placeholder.svelte"
import FieldGroupFallback from "./FieldGroupFallback.svelte" import FieldGroupFallback from "./FieldGroupFallback.svelte"
import { getContext } from "svelte" import { getContext, onDestroy } from "svelte"
export let label export let label
export let field export let field
@ -31,10 +31,13 @@
formStepContext || 1 formStepContext || 1
) )
// Expose field properties to parent component // Update form properties in parent component on every store change
$: fieldState = $formField?.fieldState const unsubscribe = formField.subscribe(value => {
$: fieldApi = $formField?.fieldApi fieldState = value?.fieldState
$: fieldSchema = $formField?.fieldSchema fieldApi = value?.fieldApi
fieldSchema = value?.fieldSchema
})
onDestroy(unsubscribe)
// Keep validation rules up to date // Keep validation rules up to date
$: updateValidation(validation) $: updateValidation(validation)