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
- Right-click on empty canvas to open the new-node menu (appears at the cursor, correctly).
- Type a single common letter, e.g.
e.
- The popup re-lays out into a multi-column grid filling the screen and is clamped to the top-left.
- 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:
- removes the category submenus, then
- adds a
QAction for every entry in node_inventory to the now-flat menu, then
- 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.
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: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.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
e.flow) — the menu shrinks to a few entries but stays at the top-left rather than returning to the cursor.Cause
In the
textEditedhandler (GNodeGUI/src/graph_viewer.cpp, inexecute_new_node_context_menu), the first keystroke:QActionfor every entry innode_inventoryto the now-flat menu, thenaction->setVisible(false).So the menu briefly holds the entire inventory. Qt lays a
QMenuthat 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 forcingSuggested 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:
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