Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions core/shortcut_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,27 +393,31 @@ 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) {
return (
!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);
}
Expand All @@ -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);
Expand Down
Loading