From 00e1e2f08991e5eb1c4f47994fa322a96233f334 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 10 Dec 2024 14:09:27 -0800 Subject: [PATCH] clean up shadow blocks in insertion markers for expandable blocks --- pxtblocks/composableMutations.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pxtblocks/composableMutations.ts b/pxtblocks/composableMutations.ts index d7a53d60e83..d3f0e52b8d7 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);