Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use queueRender rather than render #10233

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pxtblocks/composableMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pxtblocks/plugins/arrays/createList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
2 changes: 1 addition & 1 deletion pxtblocks/plugins/functions/blocks/functionCallBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 6 additions & 4 deletions pxtblocks/plugins/functions/blocks/functionDeclarationBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -157,7 +159,7 @@ const FUNCTION_DECLARATION_MIXIN: FunctionDeclarationMixin = {
type: typeName,
});
this.updateDisplay_();
this.focusLastEditor_();
/* await */ this.focusLastEditorAsync_();
},

addBooleanExternal(this: FunctionDeclarationBlock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion pxtblocks/plugins/functions/commonFunctionMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const COMMON_FUNCTION_MIXIN = {

if (wasRendered && !this.isInsertionMarker() && this instanceof Blockly.BlockSvg) {
this.initSvg();
this.render();
this.queueRender();
}
},

Expand Down
2 changes: 1 addition & 1 deletion pxtblocks/plugins/logic/ifElse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pxtblocks/plugins/text/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
Expand Down