From d3407a2444029afabe76f001b1529aff88465f1b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 18 Nov 2021 14:43:02 +0000 Subject: [PATCH] Fix bug with duplication of fields when re-registering existing fields --- .../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 432c9b2bde..1a544832d4 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -83,6 +83,8 @@ return fields.find(field => get(field).name === name) } + $: console.log(fields) + const formApi = { registerField: ( field, @@ -136,7 +138,12 @@ }) // Add this field - fields = [...fields, fieldInfo] + if (existingField) { + const otherFields = fields.filter(info => get(info).name !== field) + fields = [...otherFields, fieldInfo] + } else { + fields = [...fields, fieldInfo] + } return fieldInfo },