fix: align Home/End/Page Down shortcuts with arrow-key navigation - #10404
fix: align Home/End/Page Down shortcuts with arrow-key navigation#10404anishtsudo wants to merge 4 commits into
Conversation
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
mikeharv
left a comment
There was a problem hiding this comment.
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.
-
Navigator API:
We try to keep new Navigator methodsprivateor@internalunless we know an app needs to call them. These helpers are only used fromshortcut_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 ofshortcut_itemsthat should probably move back.Navigatormethods shouldn't need to be aware of the scoping of Home/End shortcuts. -
Tests:
Could you assert the actual destination node rather thangetLastNodeInBlock()/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. -
Rebase (due to merge conflicts)
Note that this will change some of the tests you are modifying as we've stopped usinggetFocusedNodeStubin favor of the realfocusNode()(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.
|
Moved this work to a new PR with the review follow-ups: https://github.com/RaspberryPiFoundation/blockly/pull/XXXX |
…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>
|
Brought the review follow-ups back onto this PR instead of opening a new one. Addressed the review:
Ready for another look. Thanks! |
|
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. |
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.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.jsandnavigation_test.jscovering 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.