fix(number-input): empty input should not be coerced to 0

Fixes #1031
This commit is contained in:
Eric Liu 2022-01-22 08:33:01 -08:00
commit 8f23ede636

View file

@ -131,10 +131,15 @@
let inputValue = value;
const normalizeValue = (_value) => {
if (_value === undefined || _value === "") return _value;
return Number(_value);
};
$: dispatch("change", value);
$: incrementLabel = translateWithId("increment");
$: decrementLabel = translateWithId("decrement");
$: value = Number(inputValue);
$: value = normalizeValue(inputValue);
$: error =
invalid || (!allowEmpty && value === "") || value > max || value < min;
$: errorId = `error-${id}`;