Skip to content

Conversation

@tracygardner
Copy link
Contributor

Motivation

  • Improve keyboard navigation from the search field so ArrowDown/ArrowUp focuses the selected toolbox category row instead of the toolbox container.
  • Ensure ArrowRight can move into the flyout without requiring a mouse click by focusing the category row itself.

Description

  • Stop calling toolboxDiv.focus() immediately and instead obtain the selected toolbox item via toolbox?.getSelectedItem?.() after toolbox.selectNext?.()/selectPrevious?.() and toolbox.refreshSelection?.().
  • Resolve a focusable DOM node on the selected item using getDiv?.(), htmlDiv_, svgGroup_, rowDiv_, or element_, set tabindex="0" on it if needed, and call .focus().
  • Manage a data-flock-toolbox-row attribute and ensure only the active row remains in the tab order by removing the attribute and setting tabindex=-1 on previous targets, and fall back to focusing toolboxDiv when no row element is found.
  • Preserve the call to Blockly.getFocusManager?.()?.focusTree?.(toolbox || null) after focus is adjusted.

Testing

  • No automated tests were run for this change.

Codex Task

… keys

### Motivation
- Improve keyboard navigation from the search field so ArrowDown/ArrowUp focuses the selected toolbox category row instead of the toolbox container.
- Ensure ArrowRight can move into the flyout without requiring a mouse click by focusing the category row itself.

### Description
- Stop calling `toolboxDiv.focus()` immediately and instead obtain the selected toolbox item via `toolbox?.getSelectedItem?.()` after `toolbox.selectNext?.()`/`selectPrevious?.()` and `toolbox.refreshSelection?.()`.
- Resolve a focusable DOM node on the selected item using `getDiv?.()`, `htmlDiv_`, `svgGroup_`, `rowDiv_`, or `element_`, set `tabindex="0"` on it if needed, and call `.focus()`.
- Manage a `data-flock-toolbox-row` attribute and ensure only the active row remains in the tab order by removing the attribute and setting `tabindex=-1` on previous targets, and fall back to focusing `toolboxDiv` when no row element is found.
- Preserve the call to `Blockly.getFocusManager?.()?.focusTree?.(toolbox || null)` after focus is adjusted.

### Testing
- No automated tests were run for this change.
…gating search with Arrow keys

### Motivation
- Improve keyboard navigation from the search field so ArrowDown/ArrowUp focuses the actual toolbox row (preferably the toolbox item's click target) enabling ArrowRight to move into the flyout without a mouse click.
- Ensure FocusManager's active tree is set before performing DOM focus changes to make focus state consistent with Blockly's focus system.

### Description
- Update `main/blocklyinit.js` to resolve a focusable element for the selected toolbox item, preferring `getClickTarget()` and falling back to `getDiv()`, `rowDiv_`, `htmlDiv_`, `svgGroup_`, or `element_`.
- Call `Blockly.getFocusManager?.()?.focusTree?.(toolbox || null)` immediately after selection changes and before applying DOM focus.
- Preserve tab order management by marking the active row with `data-flock-toolbox-row`, removing that attribute and setting `tabindex=-1` on previous targets, ensuring the chosen element gets `tabindex=0` (or an equivalent SVG attribute) and is focused, with a fallback to focusing the toolbox container when no row element is found.

### Testing
- No automated tests were run for this change.
…arch with Arrow keys

### Motivation
- Allow ArrowDown/ArrowUp from the search field to focus the actual selected toolbox row (preferably the toolbox item's click target) so ArrowRight can move into flyouts without a mouse.
- Ensure Blockly's focus state is consistent by setting the active focus tree before performing DOM focus changes via the `FocusManager` API.
- Preserve a single tabbable toolbox row to maintain predictable tab order and keyboard navigation.

### Description
- Remove the call to `this.searchField?.setSelectionRange?.(0, 0)` so blurring the search field does not reset selection and prevents focus transfer.
- Resolve a focus target for the selected toolbox item by preferring `getClickTarget()` and falling back to `getDiv()`, `rowDiv_`, `htmlDiv_`, `svgGroup_`, and `element_`, then mark the chosen element with `data-flock-toolbox-row` and adjust `tabindex` appropriately.
- Call `Blockly.getFocusManager?.()?.focusTree?.(toolbox || null)` immediately after updating selection, focus the resolved element (or the toolbox container as a fallback), and clear `data-flock-toolbox-row` and set `tabindex=-1` on previous targets.

### Testing
- No automated tests were run for this change.
@tracygardner tracygardner deleted the codex/update-focus-logic-for-toolbox-categories branch January 20, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants