From 2508354c53b6939636b8f9d81ed0451d3df374d4 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 10 Dec 2024 09:37:41 -0800 Subject: [PATCH] fix extra render trigger when initializing expandable blocks (#10312) --- pxtblocks/composableMutations.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pxtblocks/composableMutations.ts b/pxtblocks/composableMutations.ts index 276f98d5c21b..d7a53d60e839 100644 --- a/pxtblocks/composableMutations.ts +++ b/pxtblocks/composableMutations.ts @@ -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) { }