Skip to content

Commit

Permalink
front: send undefined to back when speed limit field is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kmer2016 committed Jan 25, 2024
1 parent e5390a5 commit bd665e2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ const SpeedInput: FC<

return (
<input
min={0}
min={1}
step={0.1}
{...attrs}
type="number"
value={kmhSpeed}
onChange={(e) => {
setKmhSpeed(e.target.value);
const newKmhSpeed = +e.target.value;
const newMsSpeed = isNumber(newKmhSpeed) ? kmhToMs(newKmhSpeed) : undefined;
const inputValue = e.target.value;
setKmhSpeed(inputValue);
const newKmhSpeed = parseFloat(inputValue);
const newMsSpeed = Number.isNaN(newKmhSpeed) ? undefined : kmhToMs(newKmhSpeed);
if (newMsSpeed !== msSpeed) onChange(newMsSpeed);
}}
/>
Expand Down

0 comments on commit bd665e2

Please sign in to comment.