From 5c43382f3f4304e3d16433689bd032a328362c46 Mon Sep 17 00:00:00 2001 From: romainvalls Date: Mon, 3 Feb 2025 11:53:07 +0100 Subject: [PATCH] front: fix track selection after timestops changes Signed-off-by: romainvalls --- front/src/reducers/osrdconf/helpers.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/front/src/reducers/osrdconf/helpers.ts b/front/src/reducers/osrdconf/helpers.ts index 5cb963c4097..d9285da2d26 100644 --- a/front/src/reducers/osrdconf/helpers.ts +++ b/front/src/reducers/osrdconf/helpers.ts @@ -4,6 +4,7 @@ import { v4 as uuidV4 } from 'uuid'; import { calculateDistanceAlongTrack } from 'applications/editor/tools/utils'; import type { ManageTrainSchedulePathProperties } from 'applications/operationalStudies/types'; +import type { OperationalPointReference } from 'common/api/osrdEditoastApi'; import { pathStepMatchesOp } from 'modules/pathfinding/utils'; import type { SuggestedOP } from 'modules/trainschedule/components/ManageTrainSchedule/types'; import { addElementAtIndex } from 'utils/array'; @@ -90,7 +91,12 @@ export function upsertPathStep(statePathSteps: (PathStep | null)[], op: Suggeste if (stepIndex >= 0) { // Because of import issues, there can be multiple ops with same position on path // To avoid updating the wrong one, we need to find the one that matches the payload - newVia = { ...newVia, id: cleanPathSteps[stepIndex].id }; // We don't need to change the id of the updated via + newVia = { + ...newVia, + id: cleanPathSteps[stepIndex].id, + track_reference: + (cleanPathSteps[stepIndex] as OperationalPointReference).track_reference || undefined, + }; // We don't need to change the id of the updated via statePathSteps[stepIndex] = newVia; } else { // Because of import issues, there can be multiple ops at position 0