From c9bf2700e342fa2b42005f663d3cb073f233b768 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 1 Feb 2021 11:14:24 +0000 Subject: [PATCH] Add form support for fields which can only use bindings rather than explicit onchange handlers --- .../src/forms/AttachmentField.svelte | 29 ++++++++++--------- .../src/forms/BooleanField.svelte | 13 +++++---- .../standard-components/src/forms/Form.svelte | 19 +++++++----- .../src/forms/LongFormField.svelte | 25 ++++++++-------- .../src/forms/SpectrumField.svelte | 15 +++++----- 5 files changed, 53 insertions(+), 48 deletions(-) diff --git a/packages/standard-components/src/forms/AttachmentField.svelte b/packages/standard-components/src/forms/AttachmentField.svelte index ba1945173d..eebcc65f97 100644 --- a/packages/standard-components/src/forms/AttachmentField.svelte +++ b/packages/standard-components/src/forms/AttachmentField.svelte @@ -1,27 +1,28 @@ - - {#if fieldState} - + + {#if mounted} + {/if} diff --git a/packages/standard-components/src/forms/BooleanField.svelte b/packages/standard-components/src/forms/BooleanField.svelte index 4292eedcbe..279542e612 100644 --- a/packages/standard-components/src/forms/BooleanField.svelte +++ b/packages/standard-components/src/forms/BooleanField.svelte @@ -13,18 +13,19 @@ const onChange = event => { fieldApi.setValue(event.target.checked) } - - // Ensure a valid boolean value is set - onMount(() => { - fieldApi.setValue($fieldState.value || false) - }) - + {#if fieldState}