@@ -393,27 +393,31 @@ export function registerRedo() {
393393 * Registers a keyboard shortcut for re-reading the current selected block's
394394 * summary with additional verbosity to help provide context on where the user
395395 * is currently navigated (for screen reader users only).
396+ *
397+ * This works when a block is selected, or some other part of a block
398+ * such as a field or icon.
396399 */
397400export function registerReadFullBlockSummary ( ) {
398- const i = ShortcutRegistry . registry . createSerializedKey ( KeyCodes . I , null ) ;
399401 const readFullBlockSummaryShortcut : KeyboardShortcut = {
400402 name : names . READ_FULL_BLOCK_SUMMARY ,
401403 preconditionFn ( workspace ) {
402404 return (
403405 ! workspace . isDragging ( ) &&
404406 ! getFocusManager ( ) . ephemeralFocusTaken ( ) &&
405407 ! ! getFocusManager ( ) . getFocusedNode ( ) &&
406- getFocusManager ( ) . getFocusedNode ( ) instanceof BlockSvg
408+ // Either a block or something that has a parent block is focused
409+ ! ! workspace . getCursor ( ) . getSourceBlock ( )
407410 ) ;
408411 } ,
409- callback ( _ , e ) {
410- const selectedBlock = getFocusManager ( ) . getFocusedNode ( ) as BlockSvg ;
412+ callback ( workspace , e ) {
413+ const selectedBlock = workspace . getCursor ( ) . getSourceBlock ( ) ;
414+ if ( ! selectedBlock ) return false ;
411415 const blockSummary = selectedBlock . computeAriaLabel ( true ) ;
412416 aria . announceDynamicAriaState ( `Current block: ${ blockSummary } ` ) ;
413417 e . preventDefault ( ) ;
414418 return true ;
415419 } ,
416- keyCodes : [ i ] ,
420+ keyCodes : [ KeyCodes . I ] ,
417421 } ;
418422 ShortcutRegistry . registry . register ( readFullBlockSummaryShortcut ) ;
419423}
@@ -434,11 +438,13 @@ export function registerReadBlockParentSummary() {
434438 ! workspace . isDragging ( ) &&
435439 ! getFocusManager ( ) . ephemeralFocusTaken ( ) &&
436440 ! ! getFocusManager ( ) . getFocusedNode ( ) &&
437- getFocusManager ( ) . getFocusedNode ( ) instanceof BlockSvg
441+ // Either a block or something that has a parent block is focused
442+ ! ! workspace . getCursor ( ) . getSourceBlock ( )
438443 ) ;
439444 } ,
440- callback ( _ , e ) {
441- const selectedBlock = getFocusManager ( ) . getFocusedNode ( ) as BlockSvg ;
445+ callback ( workspace , e ) {
446+ const selectedBlock = workspace . getCursor ( ) . getSourceBlock ( ) ;
447+ if ( ! selectedBlock ) return false ;
442448 const parentBlock = selectedBlock . getParent ( ) ;
443449 if ( parentBlock ) {
444450 const blockSummary = parentBlock . computeAriaLabel ( true ) ;
0 commit comments