Skip to content

Add contextMenu#66

Merged
colemancda merged 5 commits into
masterfrom
feature/context-menu
Jul 24, 2026
Merged

Add contextMenu#66
colemancda merged 5 commits into
masterfrom
feature/context-menu

Conversation

@colemancda

Copy link
Copy Markdown
Member

.contextMenu { … } — a menu of actions revealed by long-pressing a view.

Shape

The menu items are views, so — like .sheet and .toolbar — they can't ride on a scalar modifier. The wrapper emits a ContextMenu node whose children are [content…, menuItem…], with a contentCount prop marking the split. The interpreter wraps the content in a combinedClickable(onLongClick =) and anchors a DropdownMenu of the items to it — reusing the exact item-dispatch logic from Menu, so each item is a Button that fires its own callback and dismisses.

Verification

  • swift test — new test, 116 passing: the wrapper carries contentCount = 1, holds 1 content + 2 menu items, and a menu item's callback still reaches the closure through the hidden-child path.
  • Emulator (new "Context Menu" screen), screenshot-checked: long-pressing the "Project Alpha" row opened a dropdown anchored to it (Rename / Duplicate / Delete), and tapping Delete fired its action (status → "Deleted Alpha") and dismissed the menu. The second example's menu reads live state (Pin ⇄ Unpin).

Scope

Buttons as menu items (the common case); no submenus, no .contextMenu(menuItems:preview:) preview variant, and no primary-action overload.

@colemancda
colemancda merged commit e1dfca4 into master Jul 24, 2026
6 checks passed
@colemancda
colemancda deleted the feature/context-menu branch July 24, 2026 12:44
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