Skip to content

fix: align Home/End/Page Down shortcuts with arrow-key navigation - #10404

Open
anishtsudo wants to merge 4 commits into
RaspberryPiFoundation:mainfrom
anishtsudo:fix/navigation-shortcuts
Open

fix: align Home/End/Page Down shortcuts with arrow-key navigation#10404
anishtsudo wants to merge 4 commits into
RaspberryPiFoundation:mainfrom
anishtsudo:fix/navigation-shortcuts

Conversation

@anishtsudo

Copy link
Copy Markdown

The basics

The details

Resolves

Fixes #10186

Proposed Changes

Update the opt-in registerNavigationShortcuts() so Home, End, Page Down, and Ctrl/Cmd+End follow the same destinations as holding arrow keys, scoped to the current block, stack, or workspace.

  • Home moves to the first in-block node (usually the block itself).
  • End moves to the last in-block node on the current row, not the statement end.
  • Page Down moves to the last Down-reachable node in the stack and no longer enters inline value inputs.
  • Ctrl/Cmd+End moves to the last focusable workspace node (last stack, then Down, then In).
  • Page Up and Ctrl/Cmd+Home are unchanged.

This also stops End on a container end-statement from moving focus, and stops End on a focused container block from landing on an unreachable statement connection.

Reason for Changes

MakeCode needs these shortcuts before opting in. End previously focused the last input connection, which was wrong for C-shaped blocks.

Test Coverage

Added/updated mocha tests in shortcut_items_test.js and navigation_test.js covering both End bugs, Page Down not entering inline inputs, and Ctrl+End targeting the last focusable node.

Mocha (Chrome): Jump shortcuts + navigator helpers 26 passed; NavigationFunctions 73 passed.

Documentation

Updated the optional-shortcuts table in packages/docs/docs/guides/configure/keyboard-nav.mdx.

Additional Information

These shortcuts remain opt-in via Blockly.ShortcutItems.registerNavigationShortcuts(). They use the same In/Out/Down walks as arrow keys, so LTR/RTL follow existing navigator direction handling.

Rewrite the opt-in jump shortcuts so they follow the same destinations
as holding arrow keys, scoped to the current block, stack, or workspace.
This fixes End focusing unreachable container statement connections and
stops Page Down from walking into inline value inputs.

Fixes RaspberryPiFoundation#10186
@anishtsudo
anishtsudo requested a review from a team as a code owner September 3, 2026 19:32
@anishtsudo
anishtsudo requested a review from mikeharv September 3, 2026 19:32
@github-actions github-actions Bot added the PR: fix Fixes a bug label Sep 3, 2026

@mikeharv mikeharv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for picking this up! We will need a few changes before this can merge. None of them are a rewrite of the destination rules, which look good.

  1. Navigator API:
    We try to keep new Navigator methods private or @internal unless we know an app needs to call them. These helpers are only used from shortcut_items.ts, so making them public would lock us into supporting them as API. Several of the new methods are the same while-loop with a different step and stop condition. Could they be combined to a single private method? Some shortcut logic has been moved out of shortcut_items that should probably move back. Navigator methods shouldn't need to be aware of the scoping of Home/End shortcuts.

  2. Tests:
    Could you assert the actual destination node rather than getLastNodeInBlock() / getLastNodeInStack() as the expected value? Otherwise the tests will keep passing if the helper is wrong, as long as the shortcut still calls it. The older tests in this file are a good model.

  3. Rebase (due to merge conflicts)
    Note that this will change some of the tests you are modifying as we've stopped using getFocusedNodeStub in favor of the real focusNode() (see #10388).

…inations

Move Home/End/Page Down scoping back into shortcut_items so Navigator is not
aware of those shortcuts, and combine leftover row/stack walks into a private
walkAlong helper. Update Jump shortcut tests to use real focusNode() and
assert the actual destination node instead of the shortcut helpers.
Chrome mocha showed Ctrl/Cmd+End focuses text_2's TEXT field, the last
same-row node after walking down the last top-level stack.
@anishtsudo

Copy link
Copy Markdown
Author

Moved this work to a new PR with the review follow-ups: https://github.com/RaspberryPiFoundation/blockly/pull/XXXX
Closing this one to avoid a duplicate.

…tcuts

Resolve conflicts with current main while keeping the review follow-ups:
Home/End/Page Down stay scoped to arrow-key destinations, Navigator helpers
remain private, and toolbox/flyout paging from main is preserved.

Co-authored-by: Anish Kataria <anishkataria20@gmail.com>
@anishtsudo anishtsudo reopened this Sep 9, 2026
@anishtsudo

Copy link
Copy Markdown
Author

Brought the review follow-ups back onto this PR instead of opening a new one.

Addressed the review:

  1. Home/End/Page Down scoping is back in shortcut_items.ts. Navigator helpers are private.
  2. Jump shortcut tests now use focusNode() and assert the actual destination node.
  3. Merged latest main and resolved the conflicts.

Ready for another look. Thanks!

@mikeharv

Copy link
Copy Markdown
Contributor

Thanks for addressing those points. I'm still not ready to merge this though. The destination rules look right, but the PR is still doing a lot of extra moving, renaming, and wrapping that the we don't need. Could you take another pass with the goal of the smallest change that implements the new shortcut destinations? Once this reads as a focused behavior change, I'll be happy to look again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Additional shortcuts via registerNavigationShortcuts (Page Up / Down & Home / End)

3 participants