From 42ce2f6856e42ae6cebc2a2f2108c888440867a5 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Fri, 27 Jan 2017 15:38:49 -0800 Subject: [PATCH] Clear all active desc ids when the 'Erase Workspace' button is pressed. --- accessible/sidebar.component.js | 1 + accessible/tree.service.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/accessible/sidebar.component.js b/accessible/sidebar.component.js index 832f041d4..de5ba6ebc 100644 --- a/accessible/sidebar.component.js +++ b/accessible/sidebar.component.js @@ -90,6 +90,7 @@ blocklyApp.SidebarComponent = ng.core.Component({ }, clearWorkspace: function() { blocklyApp.workspace.clear(); + this.treeService.clearAllActiveDescs(); // The timeout is needed in order to give the blocks time to be cleared // from the workspace, and for the 'workspace is empty' button to show up. setTimeout(function() { diff --git a/accessible/tree.service.js b/accessible/tree.service.js index c928919c8..b1c51dbc4 100644 --- a/accessible/tree.service.js +++ b/accessible/tree.service.js @@ -214,6 +214,16 @@ blocklyApp.TreeService = ng.core.Class({ ' is invalid.'); } }, + clearAllActiveDescs: function() { + for (var treeId in this.activeDescendantIds_) { + var activeDesc = document.getElementById(this.getActiveDescId(treeId)); + if (activeDesc) { + activeDesc.classList.remove('blocklyActiveDescendant'); + } + } + + this.activeDescendantIds_ = {}; + }, isTreeRoot_: function(element) { return element.classList.contains('blocklyTree');