fix(blocks.js): fix #2014 #4209 FieldDropdown will change translation when drag the "sensing_of" block
This commit is contained in:
1 parent
d2c74c5198
commit
14bce895f8
1 file changed
+13
-1
+13
-1
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user