fix: insert noteB after noteA in split, not at end of array

This commit is contained in:
2026-07-31 08:15:56 +07:00
parent c60803ee2a
commit e1550c8ffe
2 changed files with 9 additions and 2 deletions
+8 -1
View File
@@ -6522,7 +6522,14 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
start_beat: splitBeat,
duration_beats: target.start_beat + target.duration_beats - splitBeat
};
setNotes(prev => prev.map(n => n.id === target.id ? noteA : n).concat([noteB]));
setNotes(prev => {
const idx = prev.findIndex(n => n.id === target.id);
if (idx === -1) return prev;
const result = [...prev];
result.splice(idx, 1, noteA);
result.splice(idx + 1, 0, noteB);
return result;
});
setSelectedNoteIds([noteA.id, noteB.id]);
showToast('Đã tách nốt!', 'info');
}