@@ -31,7 +31,6 @@ import {WorkspaceComment} from './comments/workspace_comment.js';
3131import * as common from './common.js' ;
3232import { ComponentManager } from './component_manager.js' ;
3333import { ConnectionDB } from './connection_db.js' ;
34- import { ConnectionType } from './connection_type.js' ;
3534import * as ContextMenu from './contextmenu.js' ;
3635import {
3736 ContextMenuOption ,
@@ -763,19 +762,15 @@ export class WorkspaceSvg
763762 } ) ;
764763
765764 let ariaLabel = null ;
766- if ( injectionDiv ) {
767- ariaLabel = Msg [ 'WORKSPACE_ARIA_LABEL' ] ;
768- } else if ( this . isFlyout ) {
765+ if ( this . isFlyout ) {
769766 ariaLabel = 'Flyout' ;
770767 } else if ( this . isMutator ) {
771- ariaLabel = 'Mutator' ;
768+ ariaLabel = 'Mutator Workspace ' ;
772769 } else {
773- // This case can happen in some test scenarios.
774- // TODO: Figure out when this can happen in non-test scenarios (if ever).
775- ariaLabel = 'Workspace' ;
770+ ariaLabel = Msg [ 'WORKSPACE_ARIA_LABEL' ] ;
776771 }
772+ aria . setRole ( this . svgGroup_ , aria . Role . REGION ) ;
777773 aria . setState ( this . svgGroup_ , aria . State . LABEL , ariaLabel ) ;
778- aria . setRole ( this . svgGroup_ , aria . Role . TREE ) ;
779774
780775 // Note that a <g> alone does not receive mouse events--it must have a
781776 // valid target inside it. If no background class is specified, as in the
@@ -803,7 +798,10 @@ export class WorkspaceSvg
803798 this . svgBlockCanvas_ = this . layerManager . getBlockLayer ( ) ;
804799 this . svgBubbleCanvas_ = this . layerManager . getBubbleLayer ( ) ;
805800
806- if ( ! this . isFlyout ) {
801+ if ( this . isFlyout ) {
802+ // Use the block canvas as the primary tree parent for flyout blocks.
803+ aria . setRole ( this . svgBlockCanvas_ , aria . Role . TREE ) ;
804+ } else {
807805 browserEvents . conditionalBind (
808806 this . svgGroup_ ,
809807 'pointerdown' ,
@@ -2959,61 +2957,9 @@ export class WorkspaceSvg
29592957 aria . setState ( treeItemElem , aria . State . POSINSET , index + 1 ) ;
29602958 aria . setState ( treeItemElem , aria . State . SETSIZE , focusableItems . length ) ;
29612959 aria . setState ( treeItemElem , aria . State . LEVEL , 1 ) ; // They are always top-level.
2962- if ( item instanceof BlockSvg ) {
2963- item
2964- . getChildren ( false )
2965- . forEach ( ( child ) =>
2966- this . recomputeAriaTreeItemDetailsRecursively ( child ) ,
2967- ) ;
2968- }
29692960 } ) ;
2970- } else {
2971- // TODO: Do this efficiently (probably incrementally).
2972- this . getTopBlocks ( false ) . forEach ( ( block ) =>
2973- this . recomputeAriaTreeItemDetailsRecursively ( block ) ,
2974- ) ;
29752961 }
29762962 }
2977-
2978- private recomputeAriaTreeItemDetailsRecursively ( block : BlockSvg ) {
2979- const elem = block . getFocusableElement ( ) ;
2980- const connection = block . currentConnectionCandidate ;
2981- let childPosition : number ;
2982- let parentsChildCount : number ;
2983- let hierarchyDepth : number ;
2984- if ( connection ) {
2985- // If the block is being inserted into a new location, the position is hypothetical.
2986- // TODO: Figure out how to deal with output connections.
2987- let surroundParent : BlockSvg | null ;
2988- let siblingBlocks : BlockSvg [ ] ;
2989- if ( connection . type === ConnectionType . INPUT_VALUE ) {
2990- surroundParent = connection . sourceBlock_ ;
2991- siblingBlocks = block . collectSiblingBlocks ( surroundParent ) ;
2992- // The block is being added as a child since it's input.
2993- // TODO: Figure out how to compute the correct position.
2994- childPosition = 0 ;
2995- } else {
2996- surroundParent = connection . sourceBlock_ . getSurroundParent ( ) ;
2997- siblingBlocks = block . collectSiblingBlocks ( surroundParent ) ;
2998- // The block is being added after the connected block.
2999- childPosition = siblingBlocks . indexOf ( connection . sourceBlock_ ) + 1 ;
3000- }
3001- parentsChildCount = siblingBlocks . length + 1 ;
3002- hierarchyDepth = surroundParent ?. computeLevelInWorkspace ( ) ?? 0 ;
3003- } else {
3004- const surroundParent = block . getSurroundParent ( ) ;
3005- const siblingBlocks = block . collectSiblingBlocks ( surroundParent ) ;
3006- childPosition = siblingBlocks . indexOf ( block ) ;
3007- parentsChildCount = siblingBlocks . length ;
3008- hierarchyDepth = block . computeLevelInWorkspace ( ) ;
3009- }
3010- aria . setState ( elem , aria . State . POSINSET , childPosition + 1 ) ;
3011- aria . setState ( elem , aria . State . SETSIZE , parentsChildCount ) ;
3012- aria . setState ( elem , aria . State . LEVEL , hierarchyDepth + 1 ) ;
3013- block
3014- . getChildren ( false )
3015- . forEach ( ( child ) => this . recomputeAriaTreeItemDetailsRecursively ( child ) ) ;
3016- }
30172963}
30182964
30192965/**
0 commit comments