From 29582ba0d7362da2cb55f6fbdfc0ba9943cbf335 Mon Sep 17 00:00:00 2001 From: CoryDCode Date: Wed, 16 Aug 2017 16:05:35 -0700 Subject: [PATCH] Fixing no-category toolboxes so they populate immediately, rather (#1255) than on a timeout. --- accessible/toolbox-modal.service.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/accessible/toolbox-modal.service.js b/accessible/toolbox-modal.service.js index fa860d58d..5d93cea88 100644 --- a/accessible/toolbox-modal.service.js +++ b/accessible/toolbox-modal.service.js @@ -90,24 +90,20 @@ blocklyApp.ToolboxModalService = ng.core.Class({ ); this.computeCategoriesForCreateNewGroupModal_(); } else { - // A timeout seems to be needed in order for the .children accessor to - // work correctly. var that = this; - setTimeout(function() { - // If there are no top-level categories, we create a single category - // containing all the top-level blocks. - var tmpWorkspace = new Blockly.Workspace(); - Array.from(toolboxXmlElt.children).forEach(function(topLevelNode) { - Blockly.Xml.domToBlock(tmpWorkspace, topLevelNode); - }); - - that.allToolboxCategories = [{ - categoryName: '', - blocks: tmpWorkspace.topBlocks_ - }]; - - that.computeCategoriesForCreateNewGroupModal_(); + // If there are no top-level categories, we create a single category + // containing all the top-level blocks. + var tmpWorkspace = new Blockly.Workspace(); + Array.from(toolboxXmlElt.children).forEach(function(topLevelNode) { + Blockly.Xml.domToBlock(tmpWorkspace, topLevelNode); }); + + that.allToolboxCategories = [{ + categoryName: '', + blocks: tmpWorkspace.topBlocks_ + }]; + + that.computeCategoriesForCreateNewGroupModal_(); } }, computeCategoriesForCreateNewGroupModal_: function() {