From c6cffa15eecdb14597df5f504ee6f4bf83e8b430 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 22 Mar 2022 17:28:04 +0000 Subject: [PATCH] Do not update form field value when default value changes to prevent endless loops --- .../client/src/components/app/forms/InnerForm.svelte | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/client/src/components/app/forms/InnerForm.svelte b/packages/client/src/components/app/forms/InnerForm.svelte index 1c757e131e..b82070681b 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -157,13 +157,9 @@ const { fieldState } = get(existingField) fieldId = fieldState.fieldId - // Use new default value if default value changed, - // otherwise use the current value if possible - if (defaultValue !== fieldState.defaultValue) { - initialValue = defaultValue - } else { - initialValue = fieldState.value ?? initialValue - } + // Determine the initial value for this field, reusing the current + // value if one exists + initialValue = fieldState.value ?? initialValue // If this field has already been registered and we previously had an // error set, then re-run the validator to see if we can unset it