From e06a8905c03d14b9b56e70a65c39f526e4eb9791 Mon Sep 17 00:00:00 2001 From: Benoit Simard Date: Fri, 17 Nov 2023 11:57:39 +0100 Subject: [PATCH] front: editor - compute track section length on creation - fix #3974 --- .../LinearMetadata/FormLineStringLength.tsx | 14 +++++--------- .../editor/tools/trackEdition/tool.tsx | 8 ++++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/front/src/applications/editor/components/LinearMetadata/FormLineStringLength.tsx b/front/src/applications/editor/components/LinearMetadata/FormLineStringLength.tsx index e58530ce835..3ad546ab07c 100644 --- a/front/src/applications/editor/components/LinearMetadata/FormLineStringLength.tsx +++ b/front/src/applications/editor/components/LinearMetadata/FormLineStringLength.tsx @@ -23,14 +23,10 @@ export const FormLineStringLength: React.FC = (props) => { */ useEffect(() => { const distance = getLineStringDistance(formContext.geometry); - if (formContext.isCreation) { - setTimeout(() => onChange(distance), 0); - } else { - setMin(Math.round(distance - distance * DISTANCE_ERROR_RANGE)); - setMax(Math.round(distance + distance * DISTANCE_ERROR_RANGE)); - setGeoLength(distance); - } - }, [formContext.geometry, formContext.isCreation, onChange]); + setMin(Math.round(distance - distance * DISTANCE_ERROR_RANGE)); + setMax(Math.round(distance + distance * DISTANCE_ERROR_RANGE)); + setGeoLength(distance); + }, [formContext.geometry, formContext.isCreation]); return (
@@ -49,7 +45,7 @@ export const FormLineStringLength: React.FC = (props) => { }} /> )} - {geoLength && (length < min || length > max) && ( + {geoLength > 0 && (length < min || length > max) && (

{t('Editor.errors.length-out-of-sync-with-geometry', { min, max })}.{' '}