connectSubmenuHoverToFocusStack
projects/common/interactive/menu/menu-focus-stack.ts
Description#
Route submenu hover intent through the focus stack. Watches the CngxMenuSubmenuLike.hoverIntent signal of every submenu companion registered anywhere in the menu tree and routes its edges through the same primitives keyboard and click use: a settled hover opens via CngxMenuFocusStack.openSubmenuFor (stack-tracked, first item highlighted, keyboard-visible), a settled un-hover closes via CngxMenuFocusStack.closeSubmenuFor (stack popped innermost-first). The submenu companion itself owns NO open/close mechanics for hover - it only derives intent.
The walk covers the WHOLE registered tree, not just the open chain: a
submenu whose menu drops out of the chain (popped by a chain-correcting
open, cleared by reset()) still decays its intent afterwards, and that
false edge must be observed or the bookkeeping would go stale and fire a
spurious close when the menu re-enters the chain. Items in a hidden menu
cannot produce real pointer events, so the extra tracking never opens
anything on its own.
Edge-driven, not state-reconciling: a keyboard-opened submenu whose intent
never settled true is left alone, so pointer-less operation is unchanged.
Must run in an injection context (constructor / field initializer) - it
installs an effect. Every focus-stack owner wires it once:
CngxMenuTrigger, CngxContextMenuTrigger, and CngxContextMenuFor.