From 78ae42b267a6cc2ede5500d0b0be86b0a5d5b170 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Fri, 5 Aug 2016 17:20:41 -0700 Subject: [PATCH] After marking a spot or copying a block in the workspace, move the active desc to the parent. --- accessible/tree.service.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/accessible/tree.service.js b/accessible/tree.service.js index 2c74b984a..b6cfcc251 100644 --- a/accessible/tree.service.js +++ b/accessible/tree.service.js @@ -266,6 +266,7 @@ blocklyApp.TreeService = ng.core while (dfsStack.length) { var currentNode = dfsStack.shift(); if (currentNode.tagName == 'BUTTON') { + this.moveActiveDescToParent(treeId); currentNode.click(); break; } else if (currentNode.tagName == 'INPUT') { @@ -307,16 +308,7 @@ blocklyApp.TreeService = ng.core } } else if (e.keyCode == 37) { // Left arrow key. Go up a level, if possible. - var nextNode = activeDesc.parentNode; - if (this.isButtonOrFieldNode_(activeDesc)) { - nextNode = nextNode.parentNode; - } - while (nextNode && nextNode.tagName != 'LI') { - nextNode = nextNode.parentNode; - } - if (nextNode) { - this.setActiveDesc(nextNode.id, treeId); - } + this.moveActiveDescToParent(treeId); } else if (e.keyCode == 38) { // Up arrow key. Go to the previous sibling, if possible. var prevSibling = this.getPreviousSibling(activeDesc); @@ -342,6 +334,19 @@ blocklyApp.TreeService = ng.core } } }, + moveActiveDescToParent: function(treeId) { + var activeDesc = document.getElementById(this.getActiveDescId(treeId)); + var nextNode = activeDesc.parentNode; + if (this.isButtonOrFieldNode_(activeDesc)) { + nextNode = nextNode.parentNode; + } + while (nextNode && nextNode.tagName != 'LI') { + nextNode = nextNode.parentNode; + } + if (nextNode) { + this.setActiveDesc(nextNode.id, treeId); + } + }, getFirstChild: function(element) { if (!element) { return element;