From bd665e228a83a2f3f6baaf6d7d4cfcbbf12388f6 Mon Sep 17 00:00:00 2001 From: nncluzu Date: Tue, 23 Jan 2024 15:04:29 +0100 Subject: [PATCH] front: send undefined to back when speed limit field is empty --- .../tools/rangeEdition/speedSection/SpeedInput.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/front/src/applications/editor/tools/rangeEdition/speedSection/SpeedInput.tsx b/front/src/applications/editor/tools/rangeEdition/speedSection/SpeedInput.tsx index 89d37e60f6f..fa6e8894aa0 100644 --- a/front/src/applications/editor/tools/rangeEdition/speedSection/SpeedInput.tsx +++ b/front/src/applications/editor/tools/rangeEdition/speedSection/SpeedInput.tsx @@ -21,15 +21,16 @@ const SpeedInput: FC< return ( { - 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); }} />