diff --git a/front/src/modules/timesStops/TimesStopsInput.tsx b/front/src/modules/timesStops/TimesStopsInput.tsx index 26c3637a59a..cc298669cd7 100644 --- a/front/src/modules/timesStops/TimesStopsInput.tsx +++ b/front/src/modules/timesStops/TimesStopsInput.tsx @@ -103,26 +103,21 @@ const TimesStopsInput = ({ allWaypoints, startTime, pathSteps }: TimesStopsInput if (!updatedRows[operation.fromRowIndex].isMarginValid) { newRows[operation.fromRowIndex].isMarginValid = false; setRows(newRows); - } else if ( - !rows[operation.fromRowIndex].isMarginValid && - updatedRows[operation.fromRowIndex].isMarginValid - ) { - newRows[operation.fromRowIndex].isMarginValid = true; - setRows(newRows); - } else { - const newVias = updatedRows - .filter( - (row, index) => - !isEqual(normalizeNullablesInRow(row), normalizeNullablesInRow(rows[index])) - ) - .map(({ shortSlipDistance, onStopSignal, arrival, departure, ...row }) => ({ - ...row, - arrival: durationSinceStartTime(startTime, arrival), - departure: durationSinceStartTime(startTime, departure), - receptionSignal: onStopSignalToReceptionSignal(onStopSignal, shortSlipDistance), - })); - dispatch(upsertSeveralViasFromSuggestedOP(newVias)); + return; } + + const newVias = updatedRows + .filter( + (row, index) => + !isEqual(normalizeNullablesInRow(row), normalizeNullablesInRow(rows[index])) + ) + .map(({ shortSlipDistance, onStopSignal, arrival, departure, ...row }) => ({ + ...row, + arrival: durationSinceStartTime(startTime, arrival), + departure: durationSinceStartTime(startTime, departure), + receptionSignal: onStopSignalToReceptionSignal(onStopSignal, shortSlipDistance), + })); + dispatch(upsertSeveralViasFromSuggestedOP(newVias)); }, [rows, startTime] ); diff --git a/front/src/modules/timesStops/helpers/utils.ts b/front/src/modules/timesStops/helpers/utils.ts index 5f93c3cba72..119beee1d86 100644 --- a/front/src/modules/timesStops/helpers/utils.ts +++ b/front/src/modules/timesStops/helpers/utils.ts @@ -214,6 +214,10 @@ export function updateRowTimesAndMargin( newRowData.theoreticalMargin = '0%'; } } + // Remove second unit in stopFor if inputted by mistake + if (newRowData.stopFor && /^[0-9]+ *s$/i.test(newRowData.stopFor)) { + newRowData.stopFor = newRowData.stopFor.replace(/ *s$/i, ''); + } return newRowData; }