From c7e49d8708aaa8e968a8ecbf3bfcf9f724a725cd Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 28 Jan 2023 20:14:05 +1000 Subject: [PATCH] Fix SpinBox writing NaNs into deck config Partial fix for #2353 --- ts/components/SpinBox.svelte | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ts/components/SpinBox.svelte b/ts/components/SpinBox.svelte index f7a2b389a..923067d4f 100644 --- a/ts/components/SpinBox.svelte +++ b/ts/components/SpinBox.svelte @@ -26,12 +26,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html $: if (value) stringValue = value.toFixed(decimalPlaces(step)); function update(this: HTMLInputElement): void { - value = Math.min(max, Math.max(min, parseFloat(this.value))); - if (value > max) { - value = max; - } else if (value < min) { - value = min; + const newValue = parseFloat(this.value); + if (Number.isNaN(newValue)) { + return; } + value = Math.min(max, Math.max(min, newValue)); } function handleWheel(event: WheelEvent) {