diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index 77a069e59216ac04d2f46f145df2b8225f9e4ba6..345d21e26f5a7d4e79f5a336b930be989c51bc42 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -76,14 +76,11 @@ class Blocks extends React.Component { if (prevProps.toolboxXML !== this.props.toolboxXML) { const selectedCategoryName = this.workspace.toolbox_.getSelectedItem().name_; this.workspace.updateToolbox(this.props.toolboxXML); - // Blockly throws if we don't select a category after updating the toolbox. - /** @TODO Find a way to avoid the exception without accessing private properties. */ - this.setToolboxSelectedItemByName(selectedCategoryName); + this.workspace.toolbox_.setSelectedCategoryByName(selectedCategoryName); } if (this.props.isVisible === prevProps.isVisible) { return; } - // @todo hack to resize blockly manually in case resize happened while hidden // @todo hack to reload the workspace due to gui bug #413 if (this.props.isVisible) { // Scripts tab @@ -99,20 +96,6 @@ class Blocks extends React.Component { this.detachVM(); this.workspace.dispose(); } - /** - * Select a particular category in the toolbox by specifying the category name. - * This is a workaround for a bug: @see {@link componentDidUpdate} above. - * @TODO Remove this or reimplement using only public APIs. - * @param {string} name - the name of the category to select. - */ - setToolboxSelectedItemByName (name) { - const categories = this.workspace.toolbox_.categoryMenu_.categories_; - for (let i = 0; i < categories.length; i++) { - if (categories[i].name_ === name) { - this.workspace.toolbox_.setSelectedItem(categories[i]); - } - } - } attachVM () { this.workspace.addChangeListener(this.props.vm.blockListener); this.flyoutWorkspace = this.workspace