From e317ed10bd9602669d85635acea76bcf93219a94 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 17 Jan 2025 10:46:04 -0800 Subject: [PATCH] clean up shadow blocks in insertion markers for expandable blocks (#10315) --- pxtblocks/composableMutations.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pxtblocks/composableMutations.ts b/pxtblocks/composableMutations.ts index d7a53d60e839..d3f0e52b8d74 100644 --- a/pxtblocks/composableMutations.ts +++ b/pxtblocks/composableMutations.ts @@ -350,6 +350,17 @@ export function initExpandableBlock(info: pxtc.BlocksInfo, b: Blockly.Block, def // use domToBlockInternal so that we don't trigger a render while // the block is still being initialized newBlock = Blockly.Xml.domToBlockInternal(shadow, b.workspace); + + // we don't know at this time whether the parent block is an insertion marker + // or not. doing this check lets us clean up the block in the case that it is, + // though we get an annoying flicker + setTimeout(() => { + if (newBlock.isInsertionMarker()) { + Blockly.Events.disable(); + newBlock.dispose(); + Blockly.Events.enable(); + } + }) } else { newBlock = Blockly.Xml.domToBlock(shadow, b.workspace);