diff --git a/plugins/block-shareable-procedures/src/blocks.ts b/plugins/block-shareable-procedures/src/blocks.ts index 41a62c8185..dd773f9df9 100644 --- a/plugins/block-shareable-procedures/src/blocks.ts +++ b/plugins/block-shareable-procedures/src/blocks.ts @@ -996,7 +996,6 @@ const procedureCallerUpdateShapeMixin = { * data model. */ updateParameters_: function() { - this.updateArgsMap_(); this.deleteAllArgInputs_(); this.addParametersLabel__(); this.createArgInputs_(); @@ -1009,9 +1008,13 @@ const procedureCallerUpdateShapeMixin = { * of this caller block. */ updateArgsMap_: function() { - for (const [i, p] of this.prevParams_.entries()) { + for (const [i, p] of this.getProcedureModel().getParameters().entries()) { const target = this.getInputTargetBlock(`ARG${i}`); - if (target) this.argsMap_.set(p.getId(), target); + if (target) { + this.argsMap_.set(p.getId(), target); + } else { + this.argsMap_.delete(p.getId()); + } } }, @@ -1102,6 +1105,7 @@ const procedureCallerOnChangeMixin = { if (this.disposed || this.workspace.isFlyout) return; // Blockly.Events not generated by user. Skip handling. if (!event.recordUndo) return; + if (event.type === Blockly.Events.BLOCK_MOVE) this.updateArgsMap_(); if (event.type !== Blockly.Events.BLOCK_CREATE) return; if (event.blockId !== this.id && event.ids.indexOf(this.id) === -1) return; // We already found our model, which means we don't need to create a block. diff --git a/plugins/block-shareable-procedures/test/procedure_blocks.mocha.js b/plugins/block-shareable-procedures/test/procedure_blocks.mocha.js index 9839cefb07..b2c770a8b2 100644 --- a/plugins/block-shareable-procedures/test/procedure_blocks.mocha.js +++ b/plugins/block-shareable-procedures/test/procedure_blocks.mocha.js @@ -473,6 +473,7 @@ suite('Procedures', function() { .connect(rowBlock1.outputConnection); callBlock.getInput('ARG1').connection .connect(rowBlock2.outputConnection); + globalThis.clock.runAll(); procModel.deleteParameter(1); procModel.insertParameter(param2, 0); @@ -1033,6 +1034,7 @@ suite('Procedures', function() { .connect(block1.outputConnection); callBlock.getInput('ARG1').connection .connect(block2.outputConnection); + globalThis.clock.runAll(); // Reorder the parameters. paramBlock2.previousConnection.disconnect();