@@ -8,7 +8,9 @@ export function computeBlockAriaLabel(block: Blockly.BlockSvg): string {
88 // Shadow blocks are best represented directly by their field since they
99 // effectively operate like a field does for keyboard navigation purposes.
1010 const field = Array . from ( block . getFields ( ) ) [ 0 ] ;
11- return aria . getState ( field . getFocusableElement ( ) , aria . State . LABEL ) ?? 'Unknown?' ;
11+ return (
12+ aria . getState ( field . getFocusableElement ( ) , aria . State . LABEL ) ?? 'Unknown?'
13+ ) ;
1214 }
1315
1416 const fieldLabels = [ ] ;
@@ -18,9 +20,12 @@ export function computeBlockAriaLabel(block: Blockly.BlockSvg): string {
1820 }
1921 }
2022 return fieldLabels . join ( ' ' ) ;
21- } ;
23+ }
2224
23- function collectSiblingBlocks ( block : Blockly . BlockSvg , surroundParent : Blockly . BlockSvg | null ) : Blockly . BlockSvg [ ] {
25+ function collectSiblingBlocks (
26+ block : Blockly . BlockSvg ,
27+ surroundParent : Blockly . BlockSvg | null ,
28+ ) : Blockly . BlockSvg [ ] {
2429 // NOTE TO DEVELOPERS: it's very important that these are NOT sorted. The
2530 // returned list needs to be relatively stable for consistency block indexes
2631 // read out to users via screen readers.
@@ -29,7 +34,7 @@ function collectSiblingBlocks(block: Blockly.BlockSvg, surroundParent: Blockly.B
2934 const firstSibling : Blockly . BlockSvg = surroundParent . getChildren ( false ) [ 0 ] ;
3035 const siblings : Blockly . BlockSvg [ ] = [ firstSibling ] ;
3136 let nextSibling : Blockly . BlockSvg | null = firstSibling ;
32- while ( nextSibling = nextSibling . getNextBlock ( ) ) {
37+ while ( ( nextSibling = nextSibling . getNextBlock ( ) ) ) {
3338 siblings . push ( nextSibling ) ;
3439 }
3540 return siblings ;
@@ -42,10 +47,12 @@ function collectSiblingBlocks(block: Blockly.BlockSvg, surroundParent: Blockly.B
4247function computeLevelInWorkspace ( block : Blockly . BlockSvg ) : number {
4348 const surroundParent = block . getSurroundParent ( ) ;
4449 return surroundParent ? computeLevelInWorkspace ( surroundParent ) + 1 : 0 ;
45- } ;
50+ }
4651
4752// TODO: Do this efficiently (probably centrally).
48- export function recomputeAriaTreeItemDetailsRecursively ( block : Blockly . BlockSvg ) {
53+ export function recomputeAriaTreeItemDetailsRecursively (
54+ block : Blockly . BlockSvg ,
55+ ) {
4956 const elem = block . getFocusableElement ( ) ;
5057 const connection = ( block as any ) . currentConnectionCandidate ;
5158 let childPosition : number ;
@@ -69,7 +76,9 @@ export function recomputeAriaTreeItemDetailsRecursively(block: Blockly.BlockSvg)
6976 childPosition = siblingBlocks . indexOf ( connection . sourceBlock_ ) + 2 ;
7077 }
7178 parentsChildCount = siblingBlocks . length + 1 ;
72- hierarchyDepth = surroundParent ? computeLevelInWorkspace ( surroundParent ) + 1 : 1 ;
79+ hierarchyDepth = surroundParent
80+ ? computeLevelInWorkspace ( surroundParent ) + 1
81+ : 1 ;
7382 } else {
7483 const surroundParent = block . getSurroundParent ( ) ;
7584 const siblingBlocks = collectSiblingBlocks ( block , surroundParent ) ;
@@ -80,10 +89,17 @@ export function recomputeAriaTreeItemDetailsRecursively(block: Blockly.BlockSvg)
8089 aria . setState ( elem , aria . State . POSINSET , childPosition ) ;
8190 aria . setState ( elem , aria . State . SETSIZE , parentsChildCount ) ;
8291 aria . setState ( elem , aria . State . LEVEL , hierarchyDepth ) ;
83- block . getChildren ( false ) . forEach ( ( child ) => recomputeAriaTreeItemDetailsRecursively ( child ) ) ;
92+ block
93+ . getChildren ( false )
94+ . forEach ( ( child ) => recomputeAriaTreeItemDetailsRecursively ( child ) ) ;
8495}
8596
86- export function announceDynamicAriaStateForBlock ( block : Blockly . BlockSvg , isMoving : boolean , isCanceled : boolean , newLoc ?: Blockly . utils . Coordinate ) {
97+ export function announceDynamicAriaStateForBlock (
98+ block : Blockly . BlockSvg ,
99+ isMoving : boolean ,
100+ isCanceled : boolean ,
101+ newLoc ?: Blockly . utils . Coordinate ,
102+ ) {
87103 const connection = ( block as any ) . currentConnectionCandidate ;
88104 if ( isCanceled ) {
89105 aria . announceDynamicAriaState ( 'Canceled movement' ) ;
@@ -93,7 +109,7 @@ export function announceDynamicAriaStateForBlock(block: Blockly.BlockSvg, isMovi
93109 if ( connection ) {
94110 // TODO: Figure out general detachment.
95111 // TODO: Figure out how to deal with output connections.
96- let surroundParent : Blockly . BlockSvg | null = connection . sourceBlock_ ;
112+ const surroundParent : Blockly . BlockSvg | null = connection . sourceBlock_ ;
97113 const announcementContext = [ ] ;
98114 announcementContext . push ( 'Moving' ) ; // TODO: Specialize for inserting?
99115 // NB: Old code here doesn't seem to handle parents correctly.
@@ -111,6 +127,8 @@ export function announceDynamicAriaStateForBlock(block: Blockly.BlockSvg, isMovi
111127 aria . announceDynamicAriaState ( announcementContext . join ( ' ' ) ) ;
112128 } else if ( newLoc ) {
113129 // The block is being freely dragged.
114- aria . announceDynamicAriaState ( `Moving unconstrained to coordinate x ${ Math . round ( newLoc . x ) } and y ${ Math . round ( newLoc . y ) } .` ) ;
130+ aria . announceDynamicAriaState (
131+ `Moving unconstrained to coordinate x ${ Math . round ( newLoc . x ) } and y ${ Math . round ( newLoc . y ) } .` ,
132+ ) ;
115133 }
116134}
0 commit comments