fix: single-item cross-track drag

Each track filters the item independently. Only target track
receives the inserted item. Removes duplicate state update.
This commit is contained in:
2026-07-29 11:02:03 +07:00
parent 8e8fc58082
commit 6c6a326b7d
3 changed files with 17 additions and 15 deletions
+10 -14
View File
@@ -12119,22 +12119,18 @@ const App = () => {
return { ...t, sections: resS, midiItems: resM, clips: resC };
});
}
const items = drag.itemType === 'section' ? (t.sections || []) : (t.midiItems || []);
const updatedItems = items.filter(it => it.id !== drag.itemId);
if (movedItem) {
updatedItems.push(drag.itemType === 'section'
? { ...movedItem, start: newStart }
: { ...movedItem, startTime: newStart });
}
return prev.map(t => drag.itemType === 'section'
? { ...t, sections: updatedItems }
: { ...t, midiItems: updatedItems });
return prev.map(function(tr) {
var its = drag.itemType === 'section' ? (tr.sections || []).filter(function(it) { return it.id !== drag.itemId; }) : (tr.midiItems || []).filter(function(it) { return it.id !== drag.itemId; });
if (tr.id === targetTrackId && movedItem) {
its.push(drag.itemType === 'section'
? { ...movedItem, start: newStart }
: { ...movedItem, startTime: newStart });
}
return drag.itemType === 'section' ? { ...tr, sections: its } : { ...tr, midiItems: its };
});
});
if (drag.trackId !== targetTrackId && typeof setDraggedSectionItem === 'function') {
setDraggedSectionItem(function(p) { return { ...p, trackId: targetTrackId }; });
}
if (drag.trackId !== targetTrackId) {
setDraggedSectionItem(prev => ({ ...prev, trackId: targetTrackId }));
setDraggedSectionItem(function(p) { return { ...p, trackId: targetTrackId }; });
}
};
const handleMouseUp = () => {