Skip to content

Commit

Permalink
fix extra render trigger when initializing expandable blocks (#10312)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll authored Dec 10, 2024
1 parent 82c0eaf commit 2508354
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pxtblocks/composableMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,18 @@ export function initExpandableBlock(info: pxtc.BlocksInfo, b: Blockly.Block, def
Blockly.Events.disable();

try {
const nb = Blockly.Xml.domToBlock(shadow, b.workspace);
if (nb) {
input.connection.connect(nb.outputConnection);
let newBlock: Blockly.Block;
if (!b.initialized) {
// use domToBlockInternal so that we don't trigger a render while
// the block is still being initialized
newBlock = Blockly.Xml.domToBlockInternal(shadow, b.workspace);
}
else {
newBlock = Blockly.Xml.domToBlock(shadow, b.workspace);
}

if (newBlock) {
input.connection.connect(newBlock.outputConnection);
}
} catch (e) { }

Expand Down

0 comments on commit 2508354

Please sign in to comment.