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

Fixes #1031
This commit is contained in:
Eric Liu 2022-01-22 08:58:48 -08:00 committed by GitHub
commit 222d5a90e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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}`;