fix: clip getting deselected after a drag

This commit is contained in:
Maze Winther
2025-06-25 21:08:52 +02:00
parent d1e313450d
commit f5c546d416

View File

@ -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);