fix: right-click delete no menu + scale only for brush drag

- Separate swallowContextMenuRef (not tied to rightClickDragRef) so
  menu is skipped on right-click delete
- Initial click draw uses raw pitch, not snapPitchToScale (scale only
  applies during brush-drag in mousemove)
This commit is contained in:
2026-07-25 12:34:12 +07:00
parent 0a17cc91ea
commit 221561d58a
2 changed files with 8 additions and 7 deletions
+5 -4
View File
@@ -4922,7 +4922,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
pushToUndo(notes);
setNotes(prev => prev.filter(n => n.id !== clickedNote.id));
setSelectedNoteIds(prev => prev.filter(id => id !== clickedNote.id));
rightClickDragRef.current.erasedNote = true;
swallowContextMenuRef.current = true;
showToast('Đã xóa nốt!', 'info');
} else {
rightClickDragRef.current = { active: true, startX: e.clientX, startY: e.clientY };
@@ -5056,7 +5056,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
const noteId = 'note_' + Date.now() + Math.random().toString(36).substr(2, 5);
const newNote = {
id: noteId,
pitch: snapPitchToScale(pitch, selectedScale),
pitch: pitch,
start_beat: start,
duration_beats: initialDur,
velocity: brushVelocityRef.current,
@@ -5252,8 +5252,8 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
const handleContextMenu = (e) => {
e.preventDefault();
if (rightClickDragRef.current.erasedNote) {
rightClickDragRef.current.erasedNote = false;
if (swallowContextMenuRef.current) {
swallowContextMenuRef.current = false;
return;
}
const pos = { x: e.clientX, y: e.clientY, parentKey: null };
@@ -5263,6 +5263,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
const ccDragRef = React.useRef(null);
const rightClickDragRef = React.useRef({ active: false, startX: 0, startY: 0 });
const swallowContextMenuRef = React.useRef(false);
const handleCCMouseDown = (e) => {
const canvas = ccCanvasRef.current;