From 181143935e660f6eafffa20f1c52bb2394ec0675 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 3 Feb 2021 10:53:48 +0000 Subject: [PATCH] Force number field to set numerical values only --- packages/standard-components/src/forms/StringField.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/src/forms/StringField.svelte b/packages/standard-components/src/forms/StringField.svelte index c0a5684eae..40d33cc976 100644 --- a/packages/standard-components/src/forms/StringField.svelte +++ b/packages/standard-components/src/forms/StringField.svelte @@ -11,7 +11,12 @@ let fieldApi const onBlur = event => { - fieldApi.setValue(event.target.value) + let value = event.target.value + if (type === "number") { + const float = parseFloat(value) + value = isNaN(float) ? null : float + } + fieldApi.setValue(value) }