diff --git a/pxtblocks/composableMutations.ts b/pxtblocks/composableMutations.ts index f8a475c0c46..276f98d5c21 100644 --- a/pxtblocks/composableMutations.ts +++ b/pxtblocks/composableMutations.ts @@ -253,7 +253,7 @@ export function initExpandableBlock(info: pxtc.BlocksInfo, b: Blockly.Block, def updateButtons(); if (variableInlineInputs) b.setInputsInline(visibleOptions < inlineInputModeLimit); - if (!skipRender) (b as Blockly.BlockSvg).render(); + if (!skipRender) (b as Blockly.BlockSvg).queueRender(); } function addButton(name: string, uri: string, alt: string, delta: number) { diff --git a/pxtblocks/plugins/arrays/createList.ts b/pxtblocks/plugins/arrays/createList.ts index 74cbd7ba1bc..764b835d281 100644 --- a/pxtblocks/plugins/arrays/createList.ts +++ b/pxtblocks/plugins/arrays/createList.ts @@ -176,7 +176,7 @@ const LIST_CREATE_MIXIN = { }, Blockly.config.bumpDelay); } if (block.rendered && block instanceof Blockly.BlockSvg) { - block.render(); + block.queueRender(); } Blockly.Events.setGroup(false); }, diff --git a/pxtblocks/plugins/functions/blocks/functionCallBlocks.ts b/pxtblocks/plugins/functions/blocks/functionCallBlocks.ts index 928b131d36b..f7ec8e74995 100644 --- a/pxtblocks/plugins/functions/blocks/functionCallBlocks.ts +++ b/pxtblocks/plugins/functions/blocks/functionCallBlocks.ts @@ -103,7 +103,7 @@ const FUNCTION_CALL_MIXIN: FunctionCallMixin = { newBlock.setShadow(shadowType !== "variables_get"); if (!this.isInsertionMarker() && newBlock instanceof Blockly.BlockSvg) { newBlock.initSvg(); - newBlock.render(); + newBlock.queueRender(); } } finally { Blockly.Events.enable(); diff --git a/pxtblocks/plugins/functions/blocks/functionDeclarationBlock.ts b/pxtblocks/plugins/functions/blocks/functionDeclarationBlock.ts index 6b124874b2b..7de7bf8e372 100644 --- a/pxtblocks/plugins/functions/blocks/functionDeclarationBlock.ts +++ b/pxtblocks/plugins/functions/blocks/functionDeclarationBlock.ts @@ -16,7 +16,7 @@ import { MsgKey } from "../msg"; interface FunctionDeclarationMixin extends CommonFunctionMixin { createArgumentEditor_(argumentType: string, displayName: string): Blockly.Block; - focusLastEditor_(): void; + focusLastEditorAsync_(): void; removeFieldCallback(field: Blockly.Field): void; addParam_(typeName: string, defaultName: string): void; addBooleanExternal(): void; @@ -83,7 +83,7 @@ const FUNCTION_DECLARATION_MIXIN: FunctionDeclarationMixin = { newBlock.setShadow(true); if (!this.isInsertionMarker() && newBlock instanceof Blockly.BlockSvg) { newBlock.initSvg(); - newBlock.render(); + newBlock.queueRender(); } } finally { Blockly.Events.enable(); @@ -92,7 +92,9 @@ const FUNCTION_DECLARATION_MIXIN: FunctionDeclarationMixin = { return newBlock; }, - focusLastEditor_(this: FunctionDeclarationBlock) { + async focusLastEditorAsync_(this: FunctionDeclarationBlock) { + await Blockly.renderManagement.finishQueuedRenders(); + if (this.inputList.length > 0) { let newInput = this.inputList[this.inputList.length - 2]; if (newInput.type == Blockly.inputs.inputTypes.DUMMY) { @@ -157,7 +159,7 @@ const FUNCTION_DECLARATION_MIXIN: FunctionDeclarationMixin = { type: typeName, }); this.updateDisplay_(); - this.focusLastEditor_(); + /* await */ this.focusLastEditorAsync_(); }, addBooleanExternal(this: FunctionDeclarationBlock) { diff --git a/pxtblocks/plugins/functions/blocks/functionDefinitionBlock.ts b/pxtblocks/plugins/functions/blocks/functionDefinitionBlock.ts index b2f263ca8be..d5fd4f48a8a 100644 --- a/pxtblocks/plugins/functions/blocks/functionDefinitionBlock.ts +++ b/pxtblocks/plugins/functions/blocks/functionDefinitionBlock.ts @@ -126,7 +126,7 @@ const FUNCTION_DEFINITION_MIXIN: FunctionDefinitionMixin = { newBlock.setShadow(true); if (!this.isInsertionMarker() && newBlock instanceof Blockly.BlockSvg) { newBlock.initSvg(); - newBlock.render(); + newBlock.queueRender(); } } finally { Blockly.Events.enable(); diff --git a/pxtblocks/plugins/functions/commonFunctionMixin.ts b/pxtblocks/plugins/functions/commonFunctionMixin.ts index a4ad3483c81..cb71aec440b 100644 --- a/pxtblocks/plugins/functions/commonFunctionMixin.ts +++ b/pxtblocks/plugins/functions/commonFunctionMixin.ts @@ -260,7 +260,7 @@ export const COMMON_FUNCTION_MIXIN = { if (wasRendered && !this.isInsertionMarker() && this instanceof Blockly.BlockSvg) { this.initSvg(); - this.render(); + this.queueRender(); } }, diff --git a/pxtblocks/plugins/logic/ifElse.ts b/pxtblocks/plugins/logic/ifElse.ts index b5c6f8d5abc..a5406149724 100644 --- a/pxtblocks/plugins/logic/ifElse.ts +++ b/pxtblocks/plugins/logic/ifElse.ts @@ -122,7 +122,7 @@ const IF_ELSE_MIXIN = { }, Blockly.config.bumpDelay); } if (block.rendered && block instanceof Blockly.BlockSvg) { - block.render(); + block.queueRender(); } this.restoreConnections_(); Blockly.Events.setGroup(false); diff --git a/pxtblocks/plugins/text/join.ts b/pxtblocks/plugins/text/join.ts index f22eef53c18..219dc162efc 100644 --- a/pxtblocks/plugins/text/join.ts +++ b/pxtblocks/plugins/text/join.ts @@ -96,7 +96,7 @@ const TEXT_JOIN_MUTATOR_MIXIN = { }, Blockly.config.bumpDelay); } if (block.rendered && block instanceof Blockly.BlockSvg) { - block.render(); + block.queueRender(); } Blockly.Events.setGroup(false); }, diff --git a/webapp/src/blocks.tsx b/webapp/src/blocks.tsx index 529eb1cec66..a8bd9c96d9a 100644 --- a/webapp/src/blocks.tsx +++ b/webapp/src/blocks.tsx @@ -997,7 +997,7 @@ export class Editor extends toolboxeditor.ToolboxEditor { const m = this.editor.getMetrics(); b.moveBy(m.viewWidth / 2, m.viewHeight / 3); b.initSvg(); - b.render(); + b.queueRender(); } private _loadBlocklyPromise: Promise;