From 08ee2c50e051a8d6e845c1a12fd8a6f72a3dd95c Mon Sep 17 00:00:00 2001 From: SharglutDev Date: Tue, 15 Oct 2024 13:32:59 +0200 Subject: [PATCH] front: fix space time chart scales error For a brief moment, the computed scales passed to the space time chart can be an empty array. Add a condition to be sure we render the chart only if there at least of scale. Signed-off-by: SharglutDev --- .../views/SimulationResults.tsx | 1 + .../ManchetteWithSpaceTimeChart.tsx | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/front/src/applications/operationalStudies/views/SimulationResults.tsx b/front/src/applications/operationalStudies/views/SimulationResults.tsx index 22d30734724..361e7d074d3 100644 --- a/front/src/applications/operationalStudies/views/SimulationResults.tsx +++ b/front/src/applications/operationalStudies/views/SimulationResults.tsx @@ -87,6 +87,7 @@ const SimulationResults = ({ [projectionData] ); + // TODO: remove this after closing https://github.com/OpenRailAssociation/osrd-ui/issues/648 const projectPathTrainResult = useMemo( () => projectionData?.projectedTrains.filter((train) => train.space_time_curves.length > 0) || [], diff --git a/front/src/modules/simulationResult/components/ManchetteWithSpaceTimeChart/ManchetteWithSpaceTimeChart.tsx b/front/src/modules/simulationResult/components/ManchetteWithSpaceTimeChart/ManchetteWithSpaceTimeChart.tsx index 38eb841d017..3a17299628d 100644 --- a/front/src/modules/simulationResult/components/ManchetteWithSpaceTimeChart/ManchetteWithSpaceTimeChart.tsx +++ b/front/src/modules/simulationResult/components/ManchetteWithSpaceTimeChart/ManchetteWithSpaceTimeChart.tsx @@ -66,18 +66,24 @@ const ManchetteWithSpaceTimeChartWrapper = ({ height: `${heightOfManchetteWithSpaceTimeChart - 6}px`, }} > - +new Date(p.departure_time)))} - {...spaceTimeChartProps} - > - {spaceTimeChartProps.paths.map((path) => ( - - ))} - + {/* TODO: remove this condition after closing + https://github.com/OpenRailAssociation/osrd-ui/issues/648 */} + {spaceTimeChartProps.spaceScales.length > 0 && ( + +new Date(p.departure_time)) + )} + {...spaceTimeChartProps} + > + {spaceTimeChartProps.paths.map((path) => ( + + ))} + + )}