From 707ed7419d8acc0267f0824ecc889bb8d41f75c6 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Dec 2021 14:51:19 +0000 Subject: [PATCH] Reset field value to default value if default value changes --- .../client/src/components/app/forms/InnerForm.svelte | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/app/forms/InnerForm.svelte b/packages/client/src/components/app/forms/InnerForm.svelte index 7067d33e7d..ec0db6ae4b 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -102,8 +102,15 @@ const existingField = getField(field) if (existingField) { const { fieldState } = get(existingField) - initialValue = fieldState.value ?? initialValue 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 + } } // Auto columns are always disabled