fix: multi-item drag no longer merges all items into target track

Only the dragged item (drag.itemId) crosses tracks. Other selected
items stay on their original tracks and only move horizontally.
This commit is contained in:
2026-07-29 10:42:42 +07:00
parent 0f99788d21
commit 9869566d3e
3 changed files with 16 additions and 13 deletions
+6 -7
View File
@@ -12084,12 +12084,12 @@ const App = () => {
Object.keys(drag.multiIds).forEach(function(mid) {
var info = drag.multiIds[mid];
var newVal = info.start + delta;
// Use live currentTrackMap: info.trackId is stale after cross-track moves
var isDraggedItem = mid === drag.itemId;
var currentTid = currentTrackMap.hasOwnProperty(mid) ? currentTrackMap[mid] : info.trackId;
var onCurrentTrack = currentTid === t.id;
if (onCurrentTrack) {
if (!crossTracks || t.id === targetTrackId) {
// Item is HERE and staying update position in-place
if (!crossTracks || (isDraggedItem && t.id === targetTrackId) || (!isDraggedItem && t.id === currentTid)) {
// Update position in-place (same track or non-dragged items stay)
if (info.type === 'section') {
var idx = resultSections.findIndex(function(s) { return s.id === mid; });
if (idx >= 0) resultSections[idx] = { ...resultSections[idx], start: Math.max(0, newVal) };
@@ -12101,13 +12101,13 @@ const App = () => {
if (idx >= 0) resultClips[idx] = { ...resultClips[idx], startTime: Math.max(0, newVal) };
}
} else {
// Item must leave this track
// Dragged item leaves this track
if (info.type === 'section') resultSections = resultSections.filter(function(s) { return s.id !== mid; });
else if (info.type === 'midiItem') resultMidis = resultMidis.filter(function(mx) { return mx.id !== mid; });
else if (info.type === 'clip') { var cid3 = 'default_' + t.id; resultClips = resultClips.filter(function(cx) { return cx.id !== mid && cx.id !== cid3; }); }
}
} else if (crossTracks && t.id === targetTrackId) {
// This IS the target track filter-then-upsert at new position
} else if (isDraggedItem && crossTracks && t.id === targetTrackId) {
// Only the dragged item can cross tracks insert on target
var srcItem = null;
for (var pi2 = 0; pi2 < prev.length; pi2++) {
var tr2 = prev[pi2];
@@ -12130,7 +12130,6 @@ const App = () => {
}
}
}
// else: item is on another track and we're not crossing nothing to do
});
return { ...t, sections: resultSections, midiItems: resultMidis, clips: resultClips };
}