Merge pull request #5392 from BrightLin/develop

fix(blocks.js): fix  #2014 #4209 bugs.
This commit is contained in:
chrisgarrity authored and GitHub committed 2020-10-01 10:58:59 -04:00
commit ccc262e67a
1 file changed
+13 -1
+13 -1
View File
@@ -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) {