The open-source CapCut alternative
fix: clip getting deselected after a drag
Maze Wintherf5c546d416a8
diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsxindex b9e78839..7e2089a7 100644--- a/apps/web/src/components/editor/timeline.tsx+++ b/apps/web/src/components/editor/timeline.tsx@@ -1251,6 +1251,8 @@ function TimelineTrackContent({setResizing(null);};+ const [justFinishedDrag, setJustFinishedDrag] = useState(false);+const handleClipMouseDown = (e: React.MouseEvent, clip: any) => {// Calculate the offset from the left edge of the clip to where the user clickedconst clipElement = e.currentTarget.parentElement as HTMLElement;@@ -1261,6 +1263,16 @@ function TimelineTrackContent({startDrag(e, clip.id, track.id, clip.startTime, clickOffsetTime);};+ // Reset drag flag when drag ends+ useEffect(() => {+ if (!isDragging && justFinishedDrag) {+ const timer = setTimeout(() => setJustFinishedDrag(false), 50);+ return () => clearTimeout(timer);+ } else if (isDragging && !justFinishedDrag) {+ setJustFinishedDrag(true);+ }+ }, [isDragging, justFinishedDrag]);+const handleTrackDragOver = (e: React.DragEvent) => {e.preventDefault();@@ -1766,6 +1778,11 @@ function TimelineTrackContent({onClick={(e) => {e.stopPropagation();+ // Don't handle click if we just finished dragging+ if (justFinishedDrag) {+ return;+ }+// Close context menu if it's openif (contextMenu) {setContextMenu(null);