diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index c982bfeccfed36055895a0a1dd3e117066734176..c2625ae35a70510ede89353a69e6ae3c776211e9 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -142,11 +142,7 @@ class Blocks extends React.Component { // different from the previously rendered toolbox xml. // Do not check against prevProps.toolboxXML because that may not have been rendered. if (this.props.isVisible && this.props.toolboxXML !== this._renderedToolboxXML) { - // rather than update the toolbox "sync" -- update it in the next frame - clearTimeout(this.toolboxUpdateTimeout); - this.toolboxUpdateTimeout = setTimeout(() => { - this.updateToolbox(); - }, 0); + this.requestToolboxUpdate(); } if (this.props.isVisible === prevProps.isVisible) { @@ -178,15 +174,19 @@ class Blocks extends React.Component { this.workspace.dispose(); clearTimeout(this.toolboxUpdateTimeout); } - + requestToolboxUpdate () { + clearTimeout(this.toolboxUpdateTimeout); + this.toolboxUpdateTimeout = setTimeout(() => { + this.updateToolbox(); + }, 0); + } setLocale () { this.ScratchBlocks.ScratchMsgs.setLocale(this.props.locale); this.props.vm.setLocale(this.props.locale, this.props.messages) .then(() => { this.workspace.getFlyout().setRecyclingEnabled(false); this.props.vm.refreshWorkspace(); - // refreshWorkspace will cause a toolbox update - // wait for update to go through before reenabling recycling + this.requestToolboxUpdate(); this.withToolboxUpdates(() => { this.workspace.getFlyout().setRecyclingEnabled(true); });