fix: default chord guide note's length to last edited note's length

This commit is contained in:
Xiaohan-Tian
2025-12-15 21:48:03 -08:00
parent df722abd71
commit fbd13eef9f
+4 -1
View File
@@ -5,6 +5,7 @@ import SelectionBox from './SelectionBox';
import { isModifierKeyPressed } from '../../util/osUtil'; import { isModifierKeyPressed } from '../../util/osUtil';
import { generatePianoGridBackground, getMatchingChordsForPitch } from '../../util/scaleUtil'; import { generatePianoGridBackground, getMatchingChordsForPitch } from '../../util/scaleUtil';
import type { KeySignature } from '../../core/KGProject'; import type { KeySignature } from '../../core/KGProject';
import { KGPianoRollState } from '../../core/state/KGPianoRollState';
interface PianoGridProps { interface PianoGridProps {
gridRef: MutableRefObject<HTMLDivElement | null>; gridRef: MutableRefObject<HTMLDivElement | null>;
@@ -166,6 +167,8 @@ const PianoGrid: React.FC<PianoGridProps> = ({
return highlights; return highlights;
}, [cursorPosition, matchingChords, selectedChordIndex]); }, [cursorPosition, matchingChords, selectedChordIndex]);
const lastEditedNoteLength = KGPianoRollState.instance().getLastEditedNoteLength();
// Reset selected chord index when cursor moves to a different pitch or beat // Reset selected chord index when cursor moves to a different pitch or beat
useEffect(() => { useEffect(() => {
setSelectedChordIndex(0); setSelectedChordIndex(0);
@@ -235,7 +238,7 @@ const PianoGrid: React.FC<PianoGridProps> = ({
style={{ style={{
top: yPosition, top: yPosition,
left: highlight.beat * beatWidth, left: highlight.beat * beatWidth,
width: beatWidth, width: beatWidth * lastEditedNoteLength,
height: noteHeight height: noteHeight
}} }}
/> />