From 66366b0d31fe8aa26076d8324dd4648fe3440742 Mon Sep 17 00:00:00 2001 From: ukimsanov Date: Thu, 9 Jul 2026 13:05:48 -0700 Subject: [PATCH] fix(studio): land all timeline drops at the playhead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Product decision (user, 2026-07-09): every add — OS file drop, asset-panel drop, block drop — lands at the current playhead time, not at the drop x; only the track comes from the drop position. Reverts the drop-x landing from c568f748c while keeping its zone- and overlap-aware track resolution, so external and internal drops still behave identically. --- .../src/player/components/timelineDragDrop.ts | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/studio/src/player/components/timelineDragDrop.ts b/packages/studio/src/player/components/timelineDragDrop.ts index 63182617f4..77574f3343 100644 --- a/packages/studio/src/player/components/timelineDragDrop.ts +++ b/packages/studio/src/player/components/timelineDragDrop.ts @@ -1,5 +1,6 @@ import { useCallback, useState, type RefObject } from "react"; import { TIMELINE_ASSET_MIME, TIMELINE_BLOCK_MIME } from "../../utils/timelineAssetDrop"; +import { usePlayerStore } from "../store/playerStore"; import { TRACK_H, resolveTimelineAssetDrop } from "./timelineLayout"; import type { TimelineDropCallbacks } from "./timelineCallbacks"; @@ -11,12 +12,12 @@ interface UseTimelineAssetDropOptions extends TimelineDropCallbacks { } /** - * Dropping an asset/file/block onto the timeline places it at the DROP - * POSITION — start comes from the drop x, track from the drop y. This is the - * industry-standard drag semantic (CapCut/Premiere/FCP: dragged media lands - * where you release it); playhead placement is reserved for button/shortcut - * adds (handleAddAssetAtPlayhead). External OS file drops and internal asset - * drops share this same placement path. + * Dropping an asset/file/block onto the timeline places it at the PLAYHEAD — + * start is the current playhead time, only the track comes from the drop y. + * Deliberate product choice (user preference, 2026-07-09): every add lands at + * the playhead regardless of drop x, like CapCut's add-to-timeline. External + * OS file drops and internal asset drops share this same placement path, so + * both land identically. */ export function useTimelineAssetDrop({ scrollRef, @@ -46,28 +47,23 @@ export function useTimelineAssetDrop({ (clientX: number, clientY: number): { start: number; track: number } => { const scroll = scrollRef.current; const rect = scroll?.getBoundingClientRect(); - const pps = ppsRef.current; - // Start comes from the drop x, track from the drop y. Allow dropping into - // the rendered empty space past the content end (same relaxed bound as a - // clip drag) — the composition grows to fit on commit, content-driven. - const maxDropTime = Math.max( - durationRef.current, - scroll && pps > 0 ? scroll.scrollWidth / pps : durationRef.current, - ); - return resolveTimelineAssetDrop( + // Track comes from the vertical drop position; start is the playhead. + const { track } = resolveTimelineAssetDrop( { rectLeft: rect?.left ?? 0, rectTop: rect?.top ?? 0, scrollLeft: scroll?.scrollLeft ?? 0, scrollTop: scroll?.scrollTop ?? 0, - pixelsPerSecond: pps, - duration: maxDropTime, + pixelsPerSecond: ppsRef.current, + duration: durationRef.current, trackHeight: TRACK_H, trackOrder: trackOrderRef.current, }, clientX, clientY, ); + const start = Math.max(0, usePlayerStore.getState().currentTime); + return { start, track }; }, [scrollRef, ppsRef, durationRef, trackOrderRef], );