diff --git a/src/components/InstrumentSelection.tsx b/src/components/InstrumentSelection.tsx index e32ace2..454a60c 100644 --- a/src/components/InstrumentSelection.tsx +++ b/src/components/InstrumentSelection.tsx @@ -42,8 +42,9 @@ const InstrumentSelection: React.FC = () => { }; const handleSelectInstrument = async (instrumentKey: string) => { - const instrument = instrumentKey as InstrumentType; + // If no valid target track, ignore user interaction if (!targetTrack || !(targetTrack instanceof KGMidiTrack)) return; + const instrument = instrumentKey as InstrumentType; try { await setTrackInstrument(targetTrack.getId(), instrument); } catch (err) { @@ -53,25 +54,26 @@ const InstrumentSelection: React.FC = () => { const previewImage = FLUIDR3_INSTRUMENT_MAP[currentInstrumentKey]?.image || 'piano.png'; const previewAlt = FLUIDR3_INSTRUMENT_MAP[currentInstrumentKey]?.displayName || currentInstrumentKey; - - if (!targetTrack) return null; + const hasTargetTrack = !!targetTrack; return ( -