Skip to content

Block context menu improvements for keyboard users#698

Merged
lawsie merged 7 commits into
flipcomputing:mainfrom
lawsie:move-block-kb-hint
Jul 9, 2026
Merged

Block context menu improvements for keyboard users#698
lawsie merged 7 commits into
flipcomputing:mainfrom
lawsie:move-block-kb-hint

Conversation

@lawsie

@lawsie lawsie commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

When keyboard controls are in use

  • When a block is detached (and could be attached, i.e. is not a hat block), show a context menu with keyboard shortcut hints for move (M) and delete (Del). The eye button should NOT show when the block is unattached.
Screenshot 2026-07-09 144844
  • If you then press M to move the block, the toolbar hides so you can see what you are doing
  • Keyboard users can toggle the block context menu on and off with H (for hint) - the same as clicking on the block with a mouse
Screenshot 2026-07-09 151633

In all modes

  • Block context menu on hat blocks is situated properly at the horizontal center of the hat block rather than at the center of the whole chunk of code
Screenshot 2026-07-09 151617
  • The context menu should hide when you're dragging a block (because in that situation, you can't click it!)

AI usage

Claude Sonnet 4.6 was used throughout, everything planned checked and individually approved by a human.

Summary by CodeRabbit

  • New Features

    • Added a keyboard shortcut to show or hide the block toolbar for the selected block.
    • Expanded shortcut help and added localized labels in multiple languages.
    • Improved the block toolbar so it can show a simpler, more focused set of actions in some cases.
  • Bug Fixes

    • Made toolbar behavior more reliable during pointer use and keyboard-driven block moves.
    • Improved toolbar positioning for stacked blocks to prevent awkward shifting.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new "H" keyboard shortcut to toggle the floating block toolbar, with corresponding shortcuts-help entry and locale translations across nine languages. Extends the toolbar with a Move hint badge, reworks pointer/keyboard state coordination, simplified-toolbar visibility logic, and positioning to exclude child blocks, plus a supporting CSS rule.

Changes

Block Toolbar Keyboard Toggle and Move Hint

Layer / File(s) Summary
Shortcuts help entry and locale labels
accessibility/keyboardui.js, locale/en.js, locale/de.js, locale/es.js, locale/fr.js, locale/it.js, locale/pl.js, locale/pt.js, locale/sv.js
Adds shortcut_toggle_block_toolbar entry (key H) to the shortcuts help modal and defines its translated label in each locale file.
Move hint badge and toolbar legend/CSS
ui/contextmenu.js, style.css
Adds an inert moveHint element and "M" badge to the toolbar layout and shortcut legend, and introduces .fc-block-toolbar-hint CSS to make hint elements non-interactive.
Pointer/keyboard reveal state and simplified toolbar logic
ui/contextmenu.js
Introduces pointerIsDown, pendingHoverBlock, and suppressReshowBlock state; adds pointerup/pointercancel handling and isLooseAndMovable()/updateSimplifiedToolbar() to control button visibility by lock/movability state.
Toolbar positioning without child blocks
ui/contextmenu.js
Adds getOwnBlockScreenRect() using a children-excluding bounding rectangle and updates positionBlockToolbar() to use it.
SELECTED and BLOCK_MOVE event handling updates
ui/contextmenu.js
Updates SELECTED handling to respect suppressReshowBlock and pointer state, refreshes simplified-toolbar state on block move, and sets suppression during keyboard-initiated drags.
H keydown handler for toolbar toggle
ui/contextmenu.js
Adds a document-level keydown handler for "H" that toggles the toolbar for the selected block, guarded against typing/modifier keys and stale focus.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • flipcomputing/flock#687: Extends the same floating block toolbar in ui/contextmenu.js that this PR builds the H toggle and hint/pointer-state handling on top of.
  • flipcomputing/flock#689: Both PRs modify toolbar show/hide handling in ui/contextmenu.js, including selection/pointer interactions affecting visibility.
  • flipcomputing/flock#692: Both PRs touch keyboard-shortcut/badge infrastructure in accessibility/keyboardui.js and the floating toolbar keyboard-mode/badge overlay logic in ui/contextmenu.js.

Suggested reviewers: tracygardner

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: keyboard-focused block context menu and toolbar behavior updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/contextmenu.js`:
- Around line 906-928: The simplified toolbar logic in updateSimplifiedToolbar()
and showBlockToolbar() does not hide viewBtn when isLooseAndMovable(block) is
true, so detached in-transit blocks still show View alongside the intended
minimal actions. Update the toolbar visibility rules to gate viewBtn on the
simplified state as well, and make sure the later mesh-based visibility setup in
showBlockToolbar() does not overwrite that decision; use the existing symbols
isLooseAndMovable, updateSimplifiedToolbar, viewBtn, and showBlockToolbar to
locate the fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 713f707e-fd1e-46eb-905e-01c9e1f91ab1

📥 Commits

Reviewing files that changed from the base of the PR and between c646061 and 392336a.

📒 Files selected for processing (11)
  • accessibility/keyboardui.js
  • locale/de.js
  • locale/en.js
  • locale/es.js
  • locale/fr.js
  • locale/it.js
  • locale/pl.js
  • locale/pt.js
  • locale/sv.js
  • style.css
  • ui/contextmenu.js

Comment thread ui/contextmenu.js
@lawsie lawsie merged commit 2f5ad21 into flipcomputing:main Jul 9, 2026
3 checks passed
@lawsie lawsie deleted the move-block-kb-hint branch July 9, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant