mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Improve screenreader focus behaviour when copying or moving blocks to a marked field.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user