diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index 504291036f35d8f99d61c062b53c31d7e0315dbe..278a649bd225afb13f4580ceeee3526434613136 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -221,11 +221,18 @@ class Blocks extends React.Component { } } handleExtensionAdded (blocksInfo) { - this.ScratchBlocks.defineBlocksWithJsonArray(blocksInfo.map(blockInfo => blockInfo.json)); - const dynamicBlocksXML = this.props.vm.runtime.getBlocksXML(); - const target = this.props.vm.editingTarget; - const toolboxXML = makeToolboxXML(target.isStage, target.id, dynamicBlocksXML); - this.props.updateToolboxState(toolboxXML); + // select JSON from each block info object then reject the pseudo-blocks which don't have JSON, like separators + // this actually defines blocks and MUST run regardless of the UI state + this.ScratchBlocks.defineBlocksWithJsonArray(blocksInfo.map(blockInfo => blockInfo.json).filter(x => x)); + + // update the toolbox view: this can be skipped if we're not looking at a target, etc. + const runtime = this.props.vm.runtime; + const target = runtime.getEditingTarget() || runtime.getTargetForStage(); + if (target) { + const dynamicBlocksXML = runtime.getBlocksXML(); + const toolboxXML = makeToolboxXML(target.isStage, target.id, dynamicBlocksXML); + this.props.updateToolboxState(toolboxXML); + } } handleBlocksInfoUpdate (blocksInfo) { // @todo Later we should replace this to avoid all the warnings from redefining blocks.