Skip to content

fix: fall back to Ruby items before actions in the Material ContextMenu - #78

Merged
AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/material-context-menu-items-fallback
Nov 2, 2026
Merged

AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/material-context-menu-items-fallback

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Bug

A Ruby context_menu(content, items: [...]) never opened on right-click on Android or desktop. QA confirmed this with a probe.

ContextMenuControl._getPopupItemsFromButton picks the clicked button's own list (primary_items / secondary_items / tertiary_items). When that list is empty, it fell back to actions. Ruby's canonical ContextMenu never sends actions; that key belongs to cupertino_context_menu. So with the common items: form the popup had no entries, and _showMenu sent an empty dismiss instead of opening.

Fix

The fallback order is now per-trigger list → items → actions, the same order the iOS renderer uses in #74. This adds one line in context_menu.dart. A programmatic open, where no button is pressed, still uses items.

Tests (Material)

New test/widgets/ruby_material_context_menu_items_test.dart. Each test right-clicks with a real secondary mouse button:

  • items: [Copy, Paste] with default triggers: the popup shows Copy and Paste, and no empty dismiss is sent. Choosing "Paste" sends select with b: secondary, id: 11, idx: 1, ic: 2. This failed before the fix: the popup was empty ([]).
  • secondary_items still wins over items.
  • actions stays the last fallback.

verify_pr.sh (rebased on the current base f137eec): flutter test +752, all passed. flutter analyze lib test found no issues. Flutter 3.41.2.

QA follow-up 1

@AdamMusa
AdamMusa merged commit e5c6e4e into codex/engine-initialization Nov 2, 2026
AdamMusa pushed a commit that referenced this pull request Nov 3, 2026
Review of #74 found two Material ContextMenu gaps. Both are already
closed in the merged code; this pins the one that had no test.

- An items-only menu (Ruby's ContextMenu sends `items` and the
  per-trigger lists, never `actions`): #78 made the Material renderer
  fall back to `items` before `actions` for every trigger and for a
  programmatic open, and ruby_material_context_menu_items_test.dart
  covers the right-click case.
- `primary_trigger: "long_press"`: parseContextMenuTrigger goes through
  the shared parseEnum, which #63 made compare names without case or
  underscores, so Material accepts Ruby's spelling as iOS does. Nothing
  tested it on Material.

ruby_context_menu_trigger_items_test.dart now long-presses a menu with
`primary_trigger` "long_press" and "longPress" on iOS and Android: each
shows `primary_items` (not `secondary_items`) and selecting reports
b: primary, tr: longPress. With parseEnum as it was before #63 the
Android "long_press" case fails (no menu opens). Context menu tests and
test/architecture: 317/317.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
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