Skip to content

Commit 897f764

Browse files
authored
clean up shadow blocks in insertion markers for expandable blocks (#10315)
1 parent 3509176 commit 897f764

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pxtblocks/composableMutations.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,17 @@ export function initExpandableBlock(info: pxtc.BlocksInfo, b: Blockly.Block, def
350350
// use domToBlockInternal so that we don't trigger a render while
351351
// the block is still being initialized
352352
newBlock = Blockly.Xml.domToBlockInternal(shadow, b.workspace);
353+
354+
// we don't know at this time whether the parent block is an insertion marker
355+
// or not. doing this check lets us clean up the block in the case that it is,
356+
// though we get an annoying flicker
357+
setTimeout(() => {
358+
if (newBlock.isInsertionMarker()) {
359+
Blockly.Events.disable();
360+
newBlock.dispose();
361+
Blockly.Events.enable();
362+
}
363+
})
353364
}
354365
else {
355366
newBlock = Blockly.Xml.domToBlock(shadow, b.workspace);

0 commit comments

Comments
 (0)