From 5cb5ebca9c9f8991eb518755b5c6468e70f8d16f Mon Sep 17 00:00:00 2001 From: ymayarajan3 Date: Thu, 23 May 2024 01:05:32 -0400 Subject: [PATCH] language fix --- src/containers/blocks.jsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index 0fda5115b34..675228274e4 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -126,9 +126,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)); @@ -228,7 +225,15 @@ class Blocks extends React.Component { this.props.vm.refreshWorkspace(); this.requestToolboxUpdate(); this.withToolboxUpdates(() => { - this.workspace.getFlyout().setRecyclingEnabled(true); + this.flyout = this.workspace.getFlyout(); + this.flyout.setRecyclingEnabled(true); + + 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)); }); }); }