From dbbb251a33e134f43d0c47c57e680c05ac994b2c Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Tue, 23 Apr 2024 09:45:13 -0700 Subject: [PATCH] fix: show the correct toolbox based on sprites or the stage being selected (#4) --- src/containers/blocks.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index bb7711a5167..c65f2d1e521 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -148,6 +148,7 @@ class Blocks extends React.Component { // @todo change this when blockly supports UI events addFunctionListener(this.workspace, 'translate', this.onWorkspaceMetricsChange); addFunctionListener(this.workspace, 'zoom', this.onWorkspaceMetricsChange); + this.workspace.getToolbox().selectItemByPosition(0); this.attachVM(); // Only update blocks/vm locale when visible to avoid sizing issues @@ -224,11 +225,11 @@ class Blocks extends React.Component { this.ScratchBlocks.ScratchMsgs.setLocale(this.props.locale); this.props.vm.setLocale(this.props.locale, this.props.messages) .then(() => { - // this.workspace.getFlyout().setRecyclingEnabled(false); + this.workspace.getFlyout().setRecyclingEnabled(false); this.props.vm.refreshWorkspace(); this.requestToolboxUpdate(); this.withToolboxUpdates(() => { - // this.workspace.getFlyout().setRecyclingEnabled(true); + this.workspace.getFlyout().setRecyclingEnabled(true); }); }); } @@ -239,6 +240,7 @@ class Blocks extends React.Component { // const categoryId = this.workspace.toolbox_.getSelectedItem().getId(); // const offset = this.workspace.toolbox_.getCategoryScrollOffset(); this.workspace.updateToolbox(this.props.toolboxXML); + this.workspace.refreshToolboxSelection(); this._renderedToolboxXML = this.props.toolboxXML; // In order to catch any changes that mutate the toolbox during "normal runtime"