Skip to content

feat: migrate node right-click menu to DropdownMenu primitives - #1

Draft
comfydesigner wants to merge 5 commits into
context-menu-componentfrom
node-context-menu
Draft

comfydesigner wants to merge 5 commits into
context-menu-componentfrom
node-context-menu

Conversation

@comfydesigner

Copy link
Copy Markdown
Owner

Stacked on top of Comfy-Org#13143 (base = context-menu-component).

Summary

Migrates the node right-click / "more options" menu off PrimeVue ContextMenu + Popover onto our shared DropdownMenu primitives.

Changes

  • NodeContextMenu.vue rewritten on DropdownMenu with a virtual-anchor pattern. The anchor follows canvas pan/zoom while open via useRafFn; right-click anchors to the cursor's world coordinate, kebab-button click anchors to the button's bounding box.
  • NodeContextMenuItem.vue (new) — recursive renderer for divider / color picker / shape picker / nested submenus / leaf items.
  • Color & shape pickers are now DropdownMenuSub submenus instead of separate popovers. Reka portals submenu content, so the FE-570 nested-<ul> clipping workaround that motivated SubmenuPopover no longer applies. SubmenuPopover.vue deleted (no other consumers).
  • Extensions items are grouped under a single Extensions › submenu (blocks icon) instead of a non-clickable category header. buildStructuredMenu unwraps an already-built submenu so re-structuring doesn't double-nest.
  • Right-click behavior fixes:
    • Suppress reka's opening-time focus-outside auto-dismiss within a 300ms grace window (a right-click on a widget input focuses it, which otherwise flashed the menu open→closed). Later focus-outs still dismiss normally.
    • @pointerdown.right.prevent on widget inputs (best-effort focus/selection guard).

Known follow-ups

  • Right-click still text-selects inside number widgets (ScrubableNumberInput's nested <input>); needs a focused change in that shared component.
  • Alternative considered: split right-click onto reka's native ContextMenu primitive (handles focus/selection/positioning natively) while keeping the kebab on DropdownMenu. Deferred — the unified DropdownMenu path with the grace window works and avoids two code paths.

Test plan

  • Right-click a node → menu opens at cursor, follows canvas pan/zoom.
  • Right-click a widget input → menu stays open (no flash).
  • Click canvas/another node → menu dismisses.
  • Kebab "more options" button → menu anchors to the button.
  • Color/Shape submenus open, shape shows check on current shape.
  • Extensions submenu lists extension items (and their own submenus, if any).

🤖 Generated with Claude Code

Alex and others added 5 commits June 25, 2026 18:49
- Rewrite NodeContextMenu.vue on top of our DropdownMenu/Sub primitives.
  Use the virtual-anchor pattern (fixed 0x0 trigger) with a reactive
  screen anchor that re-syncs from canvas transform each RAF tick while
  open. Pass update-position-strategy="always" so reka repositions the
  popper to follow canvas pan/zoom.
- Inline color and shape pickers as DropdownMenuSub instead of separate
  popovers. Reka portals submenu content, so the FE-570 nested-list
  clipping workaround that motivated SubmenuPopover no longer applies.
- Color submenu = grid of swatches inside DropdownMenuSubContent.
- Shape submenu = standard items with check via :checkable :checked.
- Delete SubmenuPopover.vue (no other consumers).
- Preserve the imperative show/hide/toggle/isOpen API consumed by
  useMoreOptionsMenu.registerNodeOptionsInstance.
The kebab "more options" button calls toggleNodeOptions with a click
event; right-click handlers call showNodeOptions with a contextmenu
event. Branch on event.type so the menu anchors to the button's
getBoundingClientRect (and follows it as the canvas pans/zooms) for the
click path, and keeps the world-coordinate-projected anchor for the
right-click path.
Replace the non-clickable 'Extensions' category label + flat sibling
items with a single submenu entry. Adds a subOptions?: MenuOption[]
field on MenuOption that preserves the full MenuOption shape inside the
submenu (shortcuts, icons, further nesting), and extracts a recursive
NodeContextMenuItem.vue so any depth of submenu renders consistently.
Updates the converter and its unit tests to match the new shape.
Right-click was firing mousedown first, which focuses the input. Reka-ui
DropdownMenu treats the focus change as outside the menu and immediately
closes it. Block the focus by preventing default on mousedown when the
right button is pressed; the contextmenu handler still fires normally
to open the node menu.
- Group extension items under a single "Extensions" submenu (blocks
  icon) instead of a non-clickable category header; unwrap on re-
  structure so the submenu isn't double-nested. Recursive renderer
  supports extension items with their own submenus.
- Suppress reka's opening-time focus-outside auto-dismiss (a right-click
  on a widget input focuses it) within a 300ms grace window so the menu
  no longer flashes open then closed; later focus-outs still dismiss.
- Best-effort @pointerdown.right.prevent on widget inputs.
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