diff --git a/accessible/clipboard.service.js b/accessible/clipboard.service.js
index a9be69eb5..6048e1c2c 100644
--- a/accessible/clipboard.service.js
+++ b/accessible/clipboard.service.js
@@ -116,7 +116,7 @@ blocklyApp.ClipboardService = ng.core
Blockly.Msg.PASTED_BLOCK_FROM_CLIPBOARD_MSG +
reconstitutedBlock.toString());
},
- pasteToMarkedConnection: function(block, announce) {
+ pasteToMarkedConnection: function(block) {
var xml = Blockly.Xml.blockToDom(block);
var reconstitutedBlock = Blockly.Xml.domToBlock(
blocklyApp.workspace, xml);
@@ -142,12 +142,6 @@ blocklyApp.ClipboardService = ng.core
return;
}
- if (announce) {
- alert(
- Blockly.Msg.PASTED_BLOCK_TO_MARKED_SPOT_MSG +
- reconstitutedBlock.toString());
- }
-
this.markedConnection_ = null;
return reconstitutedBlock.id;
diff --git a/accessible/toolbox-tree.component.js b/accessible/toolbox-tree.component.js
index 1397e746d..e0d13424f 100644
--- a/accessible/toolbox-tree.component.js
+++ b/accessible/toolbox-tree.component.js
@@ -45,25 +45,26 @@ blocklyApp.ToolboxTreeComponent = ng.core
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['workspaceCopyButton'], 'blockly-button')"
[attr.aria-level]="level + 2" aria-selected="false">
-
+ (click)="copyToMarkedSpot()"
+ [disabled]="!canBeCopiedToMarkedConnection()">
{{'COPY_TO_MARKED_SPOT'|translate}}
@@ -136,22 +137,36 @@ blocklyApp.ToolboxTreeComponent = ng.core
return this.utilsService.generateAriaLabelledByAttr(
mainLabel, secondLabel, isDisabled);
},
- canBeCopiedToMarkedConnection: function(block) {
- return this.clipboardService.canBeCopiedToMarkedConnection(block);
+ canBeCopiedToMarkedConnection: function() {
+ return this.clipboardService.canBeCopiedToMarkedConnection(this.block);
},
- copyToWorkspace: function(block) {
- var xml = Blockly.Xml.blockToDom(block);
+ copyToWorkspace: function() {
+ var xml = Blockly.Xml.blockToDom(this.block);
Blockly.Xml.domToBlock(blocklyApp.workspace, xml);
- alert('Added block to workspace: ' + block.toString());
+ alert('Added block to workspace: ' + this.block.toString());
},
- copyToClipboard: function(block) {
- if (this.clipboardService) {
- this.clipboardService.copy(block, true);
- }
+ copyToClipboard: function() {
+ this.clipboardService.copy(this.block, true);
},
- copyToMarkedSpot: function(block) {
- if (this.clipboardService) {
- this.clipboardService.pasteToMarkedConnection(block, true);
- }
+ copyToMarkedSpot: function() {
+ // This involves two steps:
+ // - 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.block.toString();
+
+ var newBlockId = this.clipboardService.pasteToMarkedConnection(
+ this.block);
+
+ // 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);
+
+ alert('Block copied to marked spot: ' + blockDescription);
+ });
}
});
diff --git a/accessible/workspace-tree.component.js b/accessible/workspace-tree.component.js
index 91c4c3a67..1d42d6a43 100644
--- a/accessible/workspace-tree.component.js
+++ b/accessible/workspace-tree.component.js
@@ -176,15 +176,18 @@ blocklyApp.WorkspaceTreeComponent = ng.core
var blockDescription = this.block.toString();
var newBlockId = this.clipboardService.pasteToMarkedConnection(
- this.block, false);
+ this.block);
var that = this;
this.removeBlockAndSetFocus_(this.block, function() {
that.block.dispose(true);
});
+ // 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);