From ba0e27e50a08ea103eb36a574f421775e9c9c6b1 Mon Sep 17 00:00:00 2001 From: Xiaohan-Tian <157918347+Xiaohan-Tian@users.noreply.github.com> Date: Fri, 1 May 2026 17:55:14 -0700 Subject: [PATCH] fix: few misc issues when switching between MIDI region and audio regions --- src/components/MainContent.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/MainContent.tsx b/src/components/MainContent.tsx index 444155a..ef27e98 100644 --- a/src/components/MainContent.tsx +++ b/src/components/MainContent.tsx @@ -42,6 +42,7 @@ const MainContent: React.FC = ({ setShowPianoRoll, setActiveRegionId, pianoRollMode, + openMidiPianoRoll, openSpectrogramViewer, addTrack, addAudioTrack, @@ -511,6 +512,16 @@ const MainContent: React.FC = ({ const track = tracks.find(t => t.getId().toString() === region.trackId); if (!track) return; setSelectedTrack(track.getId().toString()); + + // If the piano roll window is already open, follow the selected region's type + if (showPianoRoll) { + const coreRegion = track.getRegions().find(r => r.getId() === regionId); + if (coreRegion?.getCurrentType() === 'KGAudioRegion') { + openSpectrogramViewer(regionId); + } else if (coreRegion?.getCurrentType() === 'KGMidiRegion') { + openMidiPianoRoll(regionId); + } + } }; // Handle explicit pencil action: select region and open piano roll @@ -531,9 +542,8 @@ const MainContent: React.FC = ({ // Reuse selection logic handleRegionClick(regionId); - // Activate and show piano roll - setActiveRegionId(regionId); - setShowPianoRoll(true); + // Activate and show piano roll in midi-edit mode + openMidiPianoRoll(regionId); }; // Handle spectrogram viewer open