From 115f45f18d86cda6a17e0d7919973ec06c981df8 Mon Sep 17 00:00:00 2001 From: Maribeth Moffatt Date: Mon, 8 Dec 2025 15:46:15 -0500 Subject: [PATCH] fix: enable i shortcuts for items on blocks (#9519) --- core/shortcut_items.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/core/shortcut_items.ts b/core/shortcut_items.ts index c865b6180..499c6b5fd 100644 --- a/core/shortcut_items.ts +++ b/core/shortcut_items.ts @@ -393,9 +393,11 @@ export function registerRedo() { * Registers a keyboard shortcut for re-reading the current selected block's * summary with additional verbosity to help provide context on where the user * is currently navigated (for screen reader users only). + * + * This works when a block is selected, or some other part of a block + * such as a field or icon. */ export function registerReadFullBlockSummary() { - const i = ShortcutRegistry.registry.createSerializedKey(KeyCodes.I, null); const readFullBlockSummaryShortcut: KeyboardShortcut = { name: names.READ_FULL_BLOCK_SUMMARY, preconditionFn(workspace) { @@ -403,17 +405,19 @@ export function registerReadFullBlockSummary() { !workspace.isDragging() && !getFocusManager().ephemeralFocusTaken() && !!getFocusManager().getFocusedNode() && - getFocusManager().getFocusedNode() instanceof BlockSvg + // Either a block or something that has a parent block is focused + !!workspace.getCursor().getSourceBlock() ); }, - callback(_, e) { - const selectedBlock = getFocusManager().getFocusedNode() as BlockSvg; + callback(workspace, e) { + const selectedBlock = workspace.getCursor().getSourceBlock(); + if (!selectedBlock) return false; const blockSummary = selectedBlock.computeAriaLabel(true); aria.announceDynamicAriaState(`Current block: ${blockSummary}`); e.preventDefault(); return true; }, - keyCodes: [i], + keyCodes: [KeyCodes.I], }; ShortcutRegistry.registry.register(readFullBlockSummaryShortcut); } @@ -434,11 +438,13 @@ export function registerReadBlockParentSummary() { !workspace.isDragging() && !getFocusManager().ephemeralFocusTaken() && !!getFocusManager().getFocusedNode() && - getFocusManager().getFocusedNode() instanceof BlockSvg + // Either a block or something that has a parent block is focused + !!workspace.getCursor().getSourceBlock() ); }, - callback(_, e) { - const selectedBlock = getFocusManager().getFocusedNode() as BlockSvg; + callback(workspace, e) { + const selectedBlock = workspace.getCursor().getSourceBlock(); + if (!selectedBlock) return false; const parentBlock = selectedBlock.getParent(); if (parentBlock) { const blockSummary = parentBlock.computeAriaLabel(true);