Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion packages/blockly/core/hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ export function showHelpHint(workspace: WorkspaceSvg) {
* @param workspace The workspace.
*/
export function showBlockNavigationHint(workspace: WorkspaceSvg) {
const message = Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT'];
const shortcut = getShortcutKeysShort(
workspace.RTL ? names.NAVIGATE_LEFT : names.NAVIGATE_RIGHT,
);
const message = Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT'].replace(
'%1',
shortcut,
);
const id = blockNavigationHintId;
Toast.show(workspace, {message, id});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/blockly/msg/json/en.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@metadata": {
"author": "Ellen Spertus <ellen.spertus@gmail.com>",
"lastupdated": "2026-05-07 12:03:23.440539",
"lastupdated": "2026-05-11 14:15:58.197621",
"locale": "en",
"messagedocumentation" : "qqq"
},
Expand Down Expand Up @@ -464,7 +464,7 @@
"WORKSPACE_CONTENTS_BLOCKS_ZERO": "No blocks%2 in workspace.",
"WORKSPACE_CONTENTS_COMMENTS_MANY": " and %1 comments",
"WORKSPACE_CONTENTS_COMMENTS_ONE": " and one comment",
"KEYBOARD_NAV_BLOCK_NAVIGATION_HINT": "Use the right arrow key to navigate inside of blocks.",
"KEYBOARD_NAV_BLOCK_NAVIGATION_HINT": "Use %1 to navigate inside of blocks.",
"KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT": "Use the arrow keys to navigate.",
"BLOCK_LABEL_BEGIN_STACK": "Begin stack",
"BLOCK_LABEL_BEGIN_PREFIX": "Begin %1",
Expand Down
4 changes: 2 additions & 2 deletions packages/blockly/msg/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ Blockly.Msg.WORKSPACE_CONTENTS_COMMENTS_MANY = ' and %1 comments';
Blockly.Msg.WORKSPACE_CONTENTS_COMMENTS_ONE = ' and one comment';
/** @type {string} */
/// Message shown when a user presses Enter with a navigable block focused.
Blockly.Msg.KEYBOARD_NAV_BLOCK_NAVIGATION_HINT = 'Use the right arrow key to navigate inside of blocks.';
Blockly.Msg.KEYBOARD_NAV_BLOCK_NAVIGATION_HINT = 'Use %1 to navigate inside of blocks.';
/** @type {string} */
/// Message shown when a user presses Enter with the workspace focused.
Blockly.Msg.KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT = 'Use the arrow keys to navigate.';
Expand Down Expand Up @@ -1880,7 +1880,7 @@ Blockly.Msg.BLOCK_LABEL_HAS_INPUTS = 'has inputs';
/** @type {string} */
/// Part of an accessibility label for a block that indicates that it is
/// a statement block, i.e. that it has a next or previous connection.
/// "command" here is used in the sense of a computer command, or a
/// "command" here is used in the sense of a computer command, or a
/// command block in Scratch.
Blockly.Msg.BLOCK_LABEL_STATEMENT = 'command';
/** @type {string} */
Expand Down
33 changes: 32 additions & 1 deletion packages/blockly/tests/mocha/shortcut_items_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,11 +1367,42 @@ suite('Keyboard Shortcut Items', function () {

sinon.assert.calledWith(toastSpy, this.workspace, {
id: 'blockNavigationHint',
message: Blockly.Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT'],
message: Blockly.Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT'].replace(
'%1',
'→',
),
});
toastSpy.restore();
});

test('Shows a toast with RTL navigation hints for navigable blocks', function () {
const toolbox = document.getElementById('toolbox-test');
const ws = Blockly.inject('blocklyDiv', {
toolbox,
renderer: 'zelos',
rtl: true,
});
const toastSpy = sinon.spy(Blockly.Toast, 'show');

const block = ws.newBlock('controls_if');
block.initSvg();
block.render();
Blockly.getFocusManager().focusNode(block);

const event = createKeyDownEvent(Blockly.utils.KeyCodes.ENTER);
ws.getInjectionDiv().dispatchEvent(event);

sinon.assert.calledWith(toastSpy, ws, {
id: 'blockNavigationHint',
message: Blockly.Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT'].replace(
'%1',
'←',
),
});
toastSpy.restore();
ws.dispose();
});

// Reenable this tests once the shortcut listing shortcut has been added.
test.skip('Shows a toast with instructions to view help for non-navigable blocks', function () {
const toastSpy = sinon.spy(Blockly.Toast, 'show');
Expand Down
Loading