Skip to content

Open source CapCut alternative.

TypeScript

fix(site): first drop on an empty timeline starts the cut at 0

David Le77c1287e71c1
diff --git a/site/src/cut/components/Editor.tsx b/site/src/cut/components/Editor.tsx
index e3b6ed2a..31e1b8e8 100644
--- a/site/src/cut/components/Editor.tsx
+++ b/site/src/cut/components/Editor.tsx
@@ -733,7 +733,11 @@ export function Editor({
}
const at = timelineDropTime(e);
if (at != null) {
- void importFiles(e.dataTransfer.files, { at });
+ // The first drop on an empty timeline starts the cut at 0: a lone
+ // clip floating at the pointer time reads as broken.
+ const s = useEditor.getState();
+ const empty = s.clips.length === 0 && s.audioClips.length === 0;
+ void importFiles(e.dataTransfer.files, { at: empty ? 0 : at });
return;
}
void importFiles(e.dataTransfer.files, { mediaOnly: !overCanvas(e) });