Skip to content

New-node context menu: typing in the filter re-lays out the entire inventory and the popup jumps away from the cursor #4

Description

@barrulus

Symptom

In the new-node context menu (GraphViewer::execute_new_node_context_menu), typing into the filter box makes the popup jump away from where you're typing:

  • With a narrow filter (e.g. flow, 4 matches in Hesiod) the menu ends up parked at the top-left of the screen, far from the cursor, even though only a handful of entries are visible.
  • With a broad filter (e.g. a single letter e) almost the whole inventory matches and the menu becomes a full-screen, multi-column grid, with the text box left somewhere off at the top.

Either way you lose track of the results relative to where you're typing. It's most noticeable in a large inventory — Hesiod currently has ~302 node types.

Reproduce

  1. Right-click on empty canvas to open the new-node menu (appears at the cursor, correctly).
  2. Type a single common letter, e.g. e.
  3. The popup re-lays out into a multi-column grid filling the screen and is clamped to the top-left.
  4. Continue typing to narrow it (e.g. flow) — the menu shrinks to a few entries but stays at the top-left rather than returning to the cursor.

Cause

In the textEdited handler (GNodeGUI/src/graph_viewer.cpp, in execute_new_node_context_menu), the first keystroke:

  1. removes the category submenus, then
  2. adds a QAction for every entry in node_inventory to the now-flat menu, then
  3. hides the non-matching ones via action->setVisible(false).

So the menu briefly holds the entire inventory. Qt lays a QMenu that tall into multiple columns and clamps the popup so it fits on screen — hence the full-screen grid and the move to the top-left. Crucially, hiding actions afterwards does not restore the popup's original geometry/position, which is why a subsequently-narrow filter stays parked at the top.

The existing comment in that block already flags the approach:

// TODO not sure about this one, feels overly brute forcing

Suggested direction

Rather than add-everything-then-hide, rebuild the menu with only what matches, and keep it small so Qt has no reason to reflow or clamp it:

  • On each keystroke, populate the menu with only the matching actions instead of the full inventory.
  • Cap the number shown (e.g. ~15) with a trailing "…and N more" hint, so the menu can never exceed a screenful regardless of inventory size or how broad the filter is.
  • Re-anchor the popup to the original invocation point after the contents change, so it stays under the cursor / text box.

Happy to put up a PR if that direction looks right to you — wanted to check first since it's a behavioural change to the menu.

Environment

  • Downstream consumer: Hesiod (~302 node types), Qt6, Linux/Wayland.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: graph-editor-uxNode menu, links, selection, keyboard, layout, clipboard

    Type

    No type

    Fields

    Priority

    P3 - Normal

    Effort

    M

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions