From 4c2d6cbedcfaa8ee0d1909f440a2925e46655e8b Mon Sep 17 00:00:00 2001
From: Corey Frang <gnarf37@gmail.com>
Date: Fri, 20 Apr 2018 13:23:52 -0400
Subject: [PATCH] Re-enable toolbox updates during normal runtime

---
 src/containers/blocks.jsx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx
index 11d14442d..395ba56c7 100644
--- a/src/containers/blocks.jsx
+++ b/src/containers/blocks.jsx
@@ -74,7 +74,9 @@ class Blocks extends React.Component {
         // entire toolbox every time we reset the workspace.  We call updateToolbox as a part of
         // componentDidUpdate so the toolbox will still correctly be updated
         this.setToolboxRefreshEnabled = this.workspace.setToolboxRefreshEnabled.bind(this.workspace);
-        this.workspace.setToolboxRefreshEnabled = () => this.setToolboxRefreshEnabled(false);
+        this.workspace.setToolboxRefreshEnabled = () => {
+            this.setToolboxRefreshEnabled(false);
+        };
 
         // @todo change this when blockly supports UI events
         addFunctionListener(this.workspace, 'translate', this.onWorkspaceMetricsChange);
@@ -107,6 +109,11 @@ class Blocks extends React.Component {
             clearTimeout(this.toolboxUpdateTimeout);
             this.toolboxUpdateTimeout = setTimeout(() => {
                 this.workspace.updateToolbox(this.props.toolboxXML);
+                // In order to catch any changes that mutate the toolbox during "normal runtime"
+                // (variable changes/etc), re-enable toolbox refresh.
+                // Using the setter function will rerender the entire toolbox which we just rendered.
+                this.workspace.toolboxRefreshEnabled_ = true;
+
                 const currentCategoryPos = this.workspace.toolbox_.getCategoryPositionByName(categoryName);
                 const currentCategoryLen = this.workspace.toolbox_.getCategoryLengthByName(categoryName);
                 if (offset < currentCategoryLen) {
-- 
GitLab