Describe the bug
In js/widgets/status.js, when updating the Status Matrix widget for bpm, bpmfactor, or outputtools status fields (lines 158 and 169), the code directly accesses this.activity.blocks.blockList[statusField[0]].protoblock.staticLabels[0] without optional chaining.
If a tracked block is deleted/trashed while the Status Matrix widget is open, blockList[statusField[0]] is undefined, causing an unhandled TypeError: Cannot read properties of undefined (reading 'protoblock') console exception.
Notice that line 176 in the default switch branch already uses optional chaining (block?.protoblock?.staticLabels?.[0] || ""), but lines 158 and 169 were accidentally missed.
Steps to reproduce
- Open Music Blocks.
- Add a
bpm or outputtools block to the workspace.
- Open the Status Matrix widget.
- Trash or delete the block while the Status Matrix widget is open.
- Inspect the developer console:
TypeError: Cannot read properties of undefined (reading 'protoblock') is thrown at status.js:158 / status.js:169.
Expected behavior
status.js should use optional chaining (?.protoblock?.staticLabels?.[0] || "") consistently across all case branches (bpm, bpmfactor, and outputtools) to prevent runtime exceptions when blocks are deleted.
Cause & Code Location
In js/widgets/status.js:
- Line 158:
this.activity.blocks.blockList[statusField[0]].protoblock.staticLabels[0]
- Line 169:
this.activity.blocks.blockList[statusField[0]].protoblock.staticLabels[0]
Proposed Fix
Add optional chaining guards to lines 158 and 169 to match line 176:
label = this.activity.blocks.blockList[statusField[0]]?.protoblock?.staticLabels?.[0] || "";
Describe the bug
In
js/widgets/status.js, when updating the Status Matrix widget forbpm,bpmfactor, oroutputtoolsstatus fields (lines 158 and 169), the code directly accessesthis.activity.blocks.blockList[statusField[0]].protoblock.staticLabels[0]without optional chaining.If a tracked block is deleted/trashed while the Status Matrix widget is open,
blockList[statusField[0]]isundefined, causing an unhandledTypeError: Cannot read properties of undefined (reading 'protoblock')console exception.Notice that line 176 in the
defaultswitch branch already uses optional chaining (block?.protoblock?.staticLabels?.[0] || ""), but lines 158 and 169 were accidentally missed.Steps to reproduce
bpmoroutputtoolsblock to the workspace.TypeError: Cannot read properties of undefined (reading 'protoblock')is thrown atstatus.js:158/status.js:169.Expected behavior
status.jsshould use optional chaining (?.protoblock?.staticLabels?.[0] || "") consistently across all case branches (bpm,bpmfactor, andoutputtools) to prevent runtime exceptions when blocks are deleted.Cause & Code Location
In
js/widgets/status.js:this.activity.blocks.blockList[statusField[0]].protoblock.staticLabels[0]this.activity.blocks.blockList[statusField[0]].protoblock.staticLabels[0]Proposed Fix
Add optional chaining guards to lines 158 and 169 to match line 176: