Skip to content

feat!: Add support for keyboard navigation#9634

Open
gonfunko wants to merge 8 commits intov13from
arrow-nav
Open

feat!: Add support for keyboard navigation#9634
gonfunko wants to merge 8 commits intov13from
arrow-nav

Conversation

@gonfunko
Copy link
Contributor

The basics

The details

Proposed Changes

This PR backports the core support for keyboard navigation of the workspace, toolbox and flyout from the blockly-keyboard-experimentation repo. It also refactors things to provide a more cohesive API for interacting with navigation. The general aspirational approach is:

  • The various *_navigation_policy.ts files specify, for each kind of focusable/navigable entity in Blockly, what its parent, first child, and previous/next siblings are, from a "just the facts"/AST perspective.
  • Navigator provides methods to query the "just the facts" relationships between elements, but also provides methods that incorporate business logic to make navigation order in response to the arrow keys make sense/feel right/pass the vibe test.
  • FlyoutNavigator and ToolboxNavigator customize the business logic for navigation in a flyout and toolbox context, respectively, and operate on a set of navigation policies relevant to focusable/navigable entities that exist in those contexts
  • Every IFocusableTree provides a Navigator instance which should be used to handle navigation within that tree
  • The actual shortcuts for the arrow keys are effectively one-liners that delegate to the Navigator for the active focus tree

This means that keyboard navigation does not have to keep track of the current state/context as in the keyboard-experimentation repo, because that maps precisely to the currently focused tree, which the FocusManager already keeps track of.

I backported the navigation business logic from the add-screen-reader-support-experimental branch, where up/down move between "rows" and left/right navigate within the current "row".

Future Work

  • Navigation within the toolbox needs to be adjusted to accomodate horizontal layouts and the various start/end toolbox positions
  • Some CSS rules need to be backported to make it clearer where focus is
  • The navigation policies should be cleaned up a bit to remove some vestiges of business logic
  • Additional tests for navigation behavior should be added; the suite from the keyboard-experimentation repo was backported with LLM assistance and manual review, but additional cases should be exercised, particularly with looping enabled
  • Enter/space to act on the focused element still needs to be backported

Breaking Changes

  • MarkerManager, Marker, and LineCursor have all been removed, along with their accessors. If you were interacting with one of these classes, Navigator should be close to a drop-in replacement.
  • IFocusableTree must implement getNavigator(), which should return a Navigator instance or subclass appropriate for navigating the tree
  • Flyout no longer implements IFocusableNode or IFocusableTree. The flyout's workspace continues to implement those interfaces, and should be used in place of the flyout itself.
  • Changes have been made to several toolbox-related interfaces. If you have custom toolbox-related classes that do not inherit from those provided in Blockly, you may need to adjust your implementation to ensure that:
    • IToolbox provides a getToolboxItems() method that returns an array of all items
    • IToolboxItem provides a getParentToolbox() method that returns a reference to its containing toolbox

@gonfunko gonfunko requested a review from maribethb March 16, 2026 21:02
@gonfunko gonfunko requested a review from a team as a code owner March 16, 2026 21:02
@github-actions github-actions bot added breaking change Used to mark a PR or issue that changes our public APIs. PR: feature Adds a feature labels Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Used to mark a PR or issue that changes our public APIs. PR: feature Adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants