fix: preserve playhead session position across dropdown switch

handleSwitchMidiItem now computes new currentTime from the delta
between old and new renderBeatOffset, keeping the playhead at
the same session-absolute time instead of resetting to bar 0.
This commit is contained in:
2026-07-27 19:28:01 +07:00
parent 3ed62b3343
commit 1d3c7a7955
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -4644,6 +4644,10 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
var match = allMidiItems.find(function(m) { return m.id === itemId; });
if (!match) return;
var trk = (activeTracks || []).find(function(t) { return t.id === match._trackId; });
var newBeatOff = (match.startTime / secondsPerBar) * timeSigNum;
var spb = 60.0 / (parseInt(bpm) || 120);
var deltaSec = (renderBeatOffset - newBeatOff) * spb;
var newTime = Math.max(0, (st.currentTime || 0) + deltaSec);
setSubTabs(function(prev) {
return prev.map(function(s) {
if (s.id !== st.id) return s;
@@ -4656,7 +4660,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
instrumentProgram: trk ? trk.instrumentProgram : undefined,
instrumentName: trk ? trk.instrumentName : undefined,
note_selection: [],
currentTime: 0
currentTime: newTime
});
});
});