Refactor how activeDescendant is set. Introduce helper functions to ensure that calls like pasteAbove() preserve the focus.

This commit is contained in:
Sean Lip
2016-06-17 17:42:51 -07:00
parent 41f6f50b77
commit 3ca593273a
5 changed files with 106 additions and 74 deletions

View File

@@ -48,9 +48,10 @@ blocklyApp.WorkspaceComponent = ng.core
<div *ngIf="workspace">
<ol #tree *ngFor="#block of workspace.topBlocks_; #i = index"
tabIndex="0" role="group" class="blocklyTree blocklyWorkspaceTree"
[attr.aria-activedescendant]="getActiveDescId(tree.id)"
[attr.aria-labelledby]="workspaceTitle.id"
(keydown)="onKeypress($event, tree)">
<blockly-workspace-tree [level]=1 [block]="block" [tree]="tree">
<blockly-workspace-tree [level]=1 [block]="block" [tree]="tree" [isTopLevel]="true">
</blockly-workspace-tree>
</ol>
</div>
@@ -74,6 +75,9 @@ blocklyApp.WorkspaceComponent = ng.core
clearWorkspace: function() {
this.workspace.clear();
},
getActiveDescId: function(tree) {
return this.treeService.getActiveDescId(tree.id);
},
onWorkspaceToolbarKeypress: function(e) {
this.treeService.onWorkspaceToolbarKeypress(
e, document.activeElement.id);