diff --git a/accessible/clipboard.service.js b/accessible/clipboard.service.js index ed6d4e428..3aec5cc11 100644 --- a/accessible/clipboard.service.js +++ b/accessible/clipboard.service.js @@ -46,6 +46,13 @@ blocklyApp.ClipboardService = ng.core this.areConnectionsCompatible_(connection, superiorConnection) || this.areConnectionsCompatible_(connection, nextConnection)); }, + getMarkedConnectionBlock: function() { + if (!this.markedConnection_) { + return null; + } else { + return this.markedConnection_.getSourceBlock(); + } + }, isMovableToMarkedConnection: function(block) { // It should not be possible to move any ancestor of the block containing // the marked spot to the marked spot. @@ -53,7 +60,7 @@ blocklyApp.ClipboardService = ng.core return false; } - var markedSpotAncestorBlock = this.markedConnection_.getSourceBlock(); + var markedSpotAncestorBlock = this.getMarkedConnectionBlock(); while (markedSpotAncestorBlock) { if (markedSpotAncestorBlock.id == block.id) { return false; diff --git a/accessible/toolbox-tree.component.js b/accessible/toolbox-tree.component.js index c78c9e40b..ee1486029 100644 --- a/accessible/toolbox-tree.component.js +++ b/accessible/toolbox-tree.component.js @@ -149,11 +149,15 @@ blocklyApp.ToolboxTreeComponent = ng.core this.clipboardService.copy(this.block, true); }, copyToMarkedSpot: function() { - // This involves two steps: + // This involves the following steps: + // - Clear screenreader focus on the destination tree. // - Put the block on the destination tree. // - Change the current tree-level focus to the destination tree, and the // screenreader focus for the destination tree to the block just moved. var blockDescription = this.getBlockDescription(); + var destinationTreeId = this.treeService.getTreeIdForBlock( + this.clipboardService.getMarkedConnectionBlock().id); + this.treeService.clearActiveDesc(destinationTreeId); var newBlockId = this.clipboardService.pasteToMarkedConnection( this.block); @@ -161,7 +165,6 @@ blocklyApp.ToolboxTreeComponent = ng.core // Invoke a digest cycle, so that the DOM settles. var that = this; setTimeout(function() { - var destinationTreeId = that.treeService.getTreeIdForBlock(newBlockId); document.getElementById(destinationTreeId).focus(); that.treeService.setActiveDesc( newBlockId + 'blockRoot', destinationTreeId); diff --git a/accessible/workspace-tree.component.js b/accessible/workspace-tree.component.js index c68d3fbf4..e409c6980 100644 --- a/accessible/workspace-tree.component.js +++ b/accessible/workspace-tree.component.js @@ -203,6 +203,9 @@ blocklyApp.WorkspaceTreeComponent = ng.core // - Change the current tree-level focus to the destination tree, and the // screenreader focus for the destination tree to the block just moved. var blockDescription = this.getBlockDescription(); + var destinationTreeId = this.treeService.getTreeIdForBlock( + this.clipboardService.getMarkedConnectionBlock().id); + this.treeService.clearActiveDesc(destinationTreeId); var newBlockId = this.clipboardService.pasteToMarkedConnection( this.block); @@ -214,9 +217,6 @@ blocklyApp.WorkspaceTreeComponent = ng.core // Invoke a digest cycle, so that the DOM settles. setTimeout(function() { - var destinationTreeId = that.treeService.getTreeIdForBlock(newBlockId); - that.treeService.clearActiveDesc(destinationTreeId); - document.getElementById(destinationTreeId).focus(); that.treeService.setActiveDesc( newBlockId + 'blockRoot', destinationTreeId);