From ebbf292ffd97390a98c076b4dd4739b4b63ae161 Mon Sep 17 00:00:00 2001 From: Paul Kaplan <pkaplan@media.mit.edu> Date: Tue, 5 Feb 2019 16:35:30 -0500 Subject: [PATCH] Fix toolbox updating after see-inside. We can't rely on refreshWorkspace always causing a toolbox update, so make sure to update the toolbox manually if it is needed. --- src/containers/blocks.jsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index c982bfecc..c2625ae35 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); }); -- GitLab