Skip to content

feat: i shortcut on workspace gives overview#9677

Open
mikeharv wants to merge 1 commit intoRaspberryPiFoundation:v13from
mikeharv:i-shortcut
Open

feat: i shortcut on workspace gives overview#9677
mikeharv wants to merge 1 commit intoRaspberryPiFoundation:v13from
mikeharv:i-shortcut

Conversation

@mikeharv
Copy link
Copy Markdown
Contributor

@mikeharv mikeharv commented Apr 2, 2026

The basics

The details

Resolves

Fixes #9622

Proposed Changes

This adds a new 'i' shortcut for workspaces. If the workspace is focused, the shortcut will trigger an announcement of the current total of block stacks and workspace comments. New translation strings were added to facilitate communicating the number of stacks and comments in a grammatically accurate way. The new strings were intentionally phrased to front-load the most important information (ie. actual quantity) over contextual description (ie. "on the workspace").
See tests for sample announcement strings created using the new messages.

Reason for Changes

From linked issue:

when focused on workspace, i shortcut should tell how many stacks of blocks, how many comments, etc are on the workspace. stacks are more useful than total block count.

Test Coverage

The main new test performs a round trip through the different permutations of messages. The other test checks that the precondition logic works as expected (the workspace must be focused).

Documentation

N/A

Additional Information

I expect we'll want to make sure this new shortcut gets added to the keyboard navigation help menu/shortcuts list once that has been ported over.

@mikeharv mikeharv requested a review from a team as a code owner April 2, 2026 14:46
@mikeharv mikeharv requested a review from BenHenning April 2, 2026 14:46
@github-actions github-actions bot added the PR: feature Adds a feature label Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mikeharv! Took a first pass and has some comments, PTAL.

Note that I'm not requesting changes in case you want to switch to a different reviewer since I'm actually out until next Wednesday.


registerDefaultShortcuts();
registerKeyboardNavigationShortcuts();
registerScreenReaderShortcuts();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we actually want to keep this out, for now. The idea is we'll use an optional plugin to enable these based on user prompting.

Blockly.Msg.ARIA_WORKSPACE_COMMENTS_MANY = ' and %1 comments';
/** @type {string} */
/// ARIA live region phrase appended when there is exactly one workspace comment.
Blockly.Msg.ARIA_WORKSPACE_COMMENTS_ONE = ' and one comment'; No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please re-add EOF line terminator.

Comment on lines +707 to +708
const stacks = workspace.getTopBlocks().length;
const comments = workspace.getTopComments().length;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Perhaps use stackCount and commentCount for a bit more clarity on what's being contained in this variables (since they read a bit as arrays at the moment).

Comment on lines +424 to +428
"ARIA_WORKSPACE_BLOCKS_MANY": "%1 stacks of blocks%2 in workspace.",
"ARIA_WORKSPACE_BLOCKS_ONE": "One stack of blocks%2 in workspace.",
"ARIA_WORKSPACE_BLOCKS_ZERO": "No blocks%2 in workspace.",
"ARIA_WORKSPACE_COMMENTS_MANY": " and %1 comments",
"ARIA_WORKSPACE_COMMENTS_ONE": " and one comment"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding this a bit hard to grok, and I suspect a translator might as well. Perhaps we could be slightly repetitive to simplify things. What if we avoided the double concatenation and had four different variables for the label:

  • "%1 stacks of blocks and %2 comments in workspace."
  • "One stack of blocks and %2 comments in workspace."
  • "%1 stacks of blocks and one comment in workspace."
  • "One stack of blocks and one comment in workspace."

Separately, I'm not sure about the Msg name here. These aren't actual ARIA labels or properties, they're just strings that happen to be used as a status message to trick the screen reader into announcing them I do recognize that we will want to standardize on this, though, so perhaps @maribethb might have a suggestion. One thought might be to do something like: WORKSPACE_MANY_BLOCKS_AND_MANY_COMMENTS_SCREEN_READER_ANNOUNCEMENT_LABEL but I'm not sure sure just how specific we want to get with these.

this.liveRegion = document.getElementById('blocklyAriaAnnounce');
});

test('Announces block stacks and comments', function () {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest splitting these up a bit. The Blockly team doesn't exactly follow the arrange-act-assert structure strictly in the codebase but it's a good baseline to follow particularly for longer tests like this as more granular failures can be more informative when investigating.

@BenHenning BenHenning assigned mikeharv and unassigned BenHenning Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feature Adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants