Skip to content

Commit

Permalink
Merge pull request #354 from mitmedialab/346-error-loading-extensions…
Browse files Browse the repository at this point in the history
…-after-changing-language-to-english

initial commit of fix
  • Loading branch information
pmalacho-mit authored May 10, 2024
2 parents 72dbb25 + e02e120 commit 50a3e6a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/scratch-gui/src/containers/blocks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ class Blocks extends React.Component {
toolboxWorkspace.registerButtonCallback('MAKE_A_LIST', varListButtonCallback('list'));
toolboxWorkspace.registerButtonCallback('MAKE_A_PROCEDURE', procButtonCallback);
toolboxWorkspace.registerButtonCallback('CONNECT_MICROBIT_ROBOT', connectMicrobitRobotCallback);
this.props.vm.runtime.on(registerButtonCallbackEvent, (event) => {
toolboxWorkspace.registerButtonCallback(event, () => this.props.vm.runtime.emit(event));
});

this.props.vm.runtime.on(openUIEvent, (details) => this.props.onOpenProgrammaticModal(details));

Expand Down Expand Up @@ -217,6 +214,15 @@ class Blocks extends React.Component {
this.requestToolboxUpdate();
this.withToolboxUpdates(() => {
this.workspace.getFlyout().setRecyclingEnabled(true);

// Moved from `componentDidMount` due to strange blockly error after changing locale.
// Worth retesting after updating scratch, as this may have been addressed in later blockly versions.
const registerButtonCallback = (event) =>
this.workspace.getFlyout()
? this.workspace.registerButtonCallback(event, () => { this.props.vm.runtime.emit(event) })
: this.props.vm.runtime.off(registerButtonCallbackEvent, registerButtonCallback)

this.props.vm.runtime.on(registerButtonCallbackEvent, registerButtonCallback.bind(this));
});
});
}
Expand Down

0 comments on commit 50a3e6a

Please sign in to comment.