Fix SpinBox initially neglecting passed value (#2125)

This commit is contained in:
Matthias Metelka 2022-10-12 06:31:54 +02:00 committed by GitHub
parent dc67ed9952
commit 5c240e8561
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import IconConstrain from "./IconConstrain.svelte";
import { chevronLeft, chevronRight } from "./icons";
export let value = 1;
export let value: number;
export let step = 1;
export let min = 1;
export let max = 9999;
@ -22,7 +22,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
let stringValue: string;
$: stringValue = value.toFixed(decimalPlaces(step));
$: if (value) stringValue = value.toFixed(decimalPlaces(step));
function update(this: HTMLInputElement): void {
value = Math.min(max, Math.max(min, parseFloat(this.value)));