fix(studio): a wrong-zone aim still creates a track and a group drag keeps relocating

This commit is contained in:
Miguel Angel Simon Sierra
2026-09-19 07:03:52 -04:00
parent 079976e5b7
commit 96d545547f
2 changed files with 11 additions and 3 deletions
@@ -168,7 +168,7 @@ describe("computeDragPreview — plain horizontal drag never arms a phantom inse
expect(next.previewTrack).toBe(0);
});
it("uses the expanded row midpoint when choosing the side for an automatic insert", () => {
it("uses the expanded row midpoint when choosing the side for a group drag's automatic insert", () => {
const rowHeights = [TRACK_H + 2 * LANE_H, TRACK_H];
const dragged = clip("dragged", 0, 0, 1, 3);
const occupied = [dragged, clip("block-0", 0, 0, 1, 2), clip("block-1", 1, 0, 1, 1)];
@@ -194,8 +194,16 @@ describe("computeDragPreview — plain horizontal drag never arms a phantom inse
const next = computeDragPreview(drag, 0, clientY, {
...ctx(rowHeights, occupied),
trackOrder: [0, 1],
selectedKeys: new Set(["dragged", "block-1"]),
});
expect(next.insertRow).toBe(0);
// A single clip dropped on the same occupied lanes stays put and overwrites instead.
const single = computeDragPreview(drag, 0, clientY, {
...ctx(rowHeights, occupied),
trackOrder: [0, 1],
});
expect(single.insertRow).toBeNull();
expect(single.previewTrack).toBe(0);
});
});
@@ -111,10 +111,10 @@ export function resolveZoneDropPlacement(input: {
}
const desired = clampTrackToZone(desiredTrack, order, audioRow, isAudio);
if (!input.relocateOnOverlap && order.includes(desired)) {
const zoneTracks = order.filter((t) => audioTracks.has(t) === isAudio);
if (!input.relocateOnOverlap && zoneTracks.includes(desired)) {
return { track: desired, insertRow: null };
}
const zoneTracks = order.filter((t) => audioTracks.has(t) === isAudio);
const placement = resolvePlacement({
elements,
desiredTrack: desired,