From b9f8b760f13fc11e2a7a82d15051ae1057d01160 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 7 Mar 2025 14:48:15 -0800 Subject: [PATCH] fix initialization of custom argument editor in function dialog --- pxtblocks/plugins/functions/utils.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pxtblocks/plugins/functions/utils.ts b/pxtblocks/plugins/functions/utils.ts index bf2c5e4a4287..6779c703b12f 100644 --- a/pxtblocks/plugins/functions/utils.ts +++ b/pxtblocks/plugins/functions/utils.ts @@ -111,15 +111,13 @@ export function createCustomArgumentEditor(typeName: string, ws: Blockly.Workspa } function createCustomArgumentBlock(blockType: string, typeName: string, ws: Blockly.Workspace) { - const block = Blockly.utils.xml.createElement("block"); - block.setAttribute("type", blockType); - + const block = ws.newBlock(blockType); const mutation = Blockly.utils.xml.createElement("mutation"); mutation.setAttribute("typename", typeName); - block.appendChild(mutation); + block.domToMutation(mutation); - return Blockly.Xml.domToBlock(block, ws); + return block; } export function findLegalName(name: string, ws: Blockly.Workspace, block?: CommonFunctionBlock) {