From e06115b8eed5b23618e4321197395feb41cf7ee8 Mon Sep 17 00:00:00 2001 From: Yiannis Christodoulou Date: Mon, 13 Oct 2025 01:40:03 +0300 Subject: [PATCH] fix: Chapters: If adding a chapter between two existing chapters, the order of the chapters are wrong in the editor timeline, and in the player chapter view --- .../client/src/components/TimelineControls.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx b/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx index 89e4a8b4..032977b5 100644 --- a/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx +++ b/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx @@ -1878,7 +1878,9 @@ const TimelineControls = ({ // Render the clip segments on the timeline const renderClipSegments = () => { - return clipSegments.map((segment, index) => { + // Sort segments by start time to ensure correct chronological order + const sortedSegments = [...clipSegments].sort((a, b) => a.startTime - b.startTime); + return sortedSegments.map((segment, index) => { const startPercent = (segment.startTime / duration) * 100; const widthPercent = ((segment.endTime - segment.startTime) / duration) * 100;