Clear all active desc ids when the 'Erase Workspace' button is pressed.

This commit is contained in:
Sean Lip
2017-01-27 15:38:49 -08:00
parent fe92d75793
commit 42ce2f6856
2 changed files with 11 additions and 0 deletions

View File

@@ -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() {

View File

@@ -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');