diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-06-25 21:08:52 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-06-25 21:08:52 +0200 |
| commit | f5c546d416a84d577f45a1fdb79e5e67e5a9495c (patch) | |
| tree | aeed8ff05f683ad2aef21a5a24b060c77f663a35 /apps/web | |
| parent | d1e313450db64c95237ebcefe928dbde39043fee (diff) | |
| download | opencut-f5c546d416a84d577f45a1fdb79e5e67e5a9495c.tar.gz | |
fix: clip getting deselected after a drag
Diffstat (limited to 'apps/web')
| -rw-r--r-- | apps/web/src/components/editor/timeline.tsx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 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 clicked
const 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 open
if (contextMenu) {
setContextMenu(null);
|
