diff --git a/src/lib/blocks.js b/src/lib/blocks.js index 892218dbe..809a77ce2 100644 --- a/src/lib/blocks.js +++ b/src/lib/blocks.js @@ -213,6 +213,18 @@ export default function (vm) { ScratchBlocks.Blocks.sensing_of.init = function () { const blockId = this.id; + const blockType = this.type; + + // Get the sensing_of block from vm. + let defaultSensingOfBlock; + const blocks = vm.runtime.flyoutBlocks._blocks; + Object.keys(blocks).forEach(id => { + const block = blocks[id]; + if (id === blockType || (block && block.opcode === blockType)) { + defaultSensingOfBlock = block; + } + }); + // Function that fills in menu for the first input in the sensing block. // Called every time it opens since it depends on the values in the other block input. const menuFn = function () { @@ -236,7 +248,7 @@ export default function (vm) { // The block doesn't exist, but should be in the flyout. Look there. if (!sensingOfBlock) { - sensingOfBlock = vm.runtime.flyoutBlocks.getBlock(blockId); + sensingOfBlock = vm.runtime.flyoutBlocks.getBlock(blockId) || defaultSensingOfBlock; // If we still don't have a block, just return an empty list . This happens during // scratch blocks construction. if (!sensingOfBlock) {