fix: move Ctrl+A useEffect after notes declaration to avoid TDZ error
This commit is contained in:
+12
-12
@@ -4563,18 +4563,6 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
window.addEventListener('mouseup', up);
|
window.addEventListener('mouseup', up);
|
||||||
return () => window.removeEventListener('mouseup', up);
|
return () => window.removeEventListener('mouseup', up);
|
||||||
}, []);
|
}, []);
|
||||||
React.useEffect(() => {
|
|
||||||
const handler = (e) => {
|
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
|
|
||||||
const target = e.target;
|
|
||||||
if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable)) return;
|
|
||||||
e.preventDefault();
|
|
||||||
setSelectedNoteIds(notes.map(n => n.id));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
window.addEventListener('keydown', handler);
|
|
||||||
return () => window.removeEventListener('keydown', handler);
|
|
||||||
}, [notes, setSelectedNoteIds]);
|
|
||||||
|
|
||||||
const NoteHeight = 18;
|
const NoteHeight = 18;
|
||||||
const PITCH_START = 0; // C0 (render all 128 keys)
|
const PITCH_START = 0; // C0 (render all 128 keys)
|
||||||
@@ -4598,6 +4586,18 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, onClose, onUpdateNot
|
|||||||
const notesRef = React.useRef(notes);
|
const notesRef = React.useRef(notes);
|
||||||
notesRef.current = notes;
|
notesRef.current = notes;
|
||||||
React.useEffect(() => { setNotes(st.notes || []); }, [st.notes]);
|
React.useEffect(() => { setNotes(st.notes || []); }, [st.notes]);
|
||||||
|
React.useEffect(() => {
|
||||||
|
const handler = (e) => {
|
||||||
|
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
|
||||||
|
const target = e.target;
|
||||||
|
if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable)) return;
|
||||||
|
e.preventDefault();
|
||||||
|
setSelectedNoteIds(notes.map(n => n.id));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener('keydown', handler);
|
||||||
|
return () => window.removeEventListener('keydown', handler);
|
||||||
|
}, [notes, setSelectedNoteIds]);
|
||||||
const brushVelocityRef = React.useRef(0.8);
|
const brushVelocityRef = React.useRef(0.8);
|
||||||
const [selectedNoteIds, setSelectedNoteIds] = React.useState([]);
|
const [selectedNoteIds, setSelectedNoteIds] = React.useState([]);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user