Skip to main content
cngx-src documentation

CngxContextMenuTriggerCore

Interface

projects/common/interactive/menu/context-menu-trigger-core.ts

Import#

import { CngxContextMenuTriggerCore } from '@cngx/common/interactive'

Description#

Shared context-menu trigger core. Owns the contextmenu / Shift+F10 handling, the transient pointer-anchor lifecycle, the dismiss binding, announcer calls, and focus save/restore. Consumed by both CngxContextMenuTrigger (directive) and CngxContextMenuFor (organism trigger) so the two share one implementation without inheritance.

Index#

Instance Properties#

Readonly

The core's submenu focus-stack model. Exposed for host-side wiring the pure factory cannot install itself - the DI hosts pass it to connectSubmenuHoverToFocusStack (an effect, so it needs their injection context) to route submenu hover intent through the stack.

lastDismissSource#Signal
Readonly

The dismissal source that closed the menu most recently.

Methods#

destroy#void

Teardown - call from the directive's DestroyRef.onDestroy.

handleContextMenu#void
handleContextMenu(event: MouseEvent)

contextmenu host handler - consults resolveOpen before opening.

@parameventMouseEvent
handleKeydown#void
handleKeydown(event: KeyboardEvent)

Keydown host handler - Shift+F10 opens at the host centre.

@parameventKeyboardEvent
noteActiveSubmenuOpened#void

Record that the active item's submenu is already open, pushing it onto the focus stack WITHOUT re-opening it. Safety net for opens the stack did not perform itself - the organism panel forwards it from the item's openAsSubmenu terminal, covering programmatic opens; for hover and click the stack already opened the submenu and this is an idempotent no-op. No-op on a leaf.

openActiveSubmenu#void

Open the submenu of the effective menu's active item through the focus stack. No-op when the active item is a leaf (or nothing is active) and idempotent when that submenu is already open. The DI host wires the surrounding menu's CngxActiveDescendant.activated output to this method so pointer click and Enter/Space open a submenu parent deterministically, off the activated event rather than a forwarded keydown that races the AD's own listener. No activated subscription lives inside this pure factory - only the imperative open.

standDown#void

Relinquish an open WITHOUT restoring focus: detach the dismiss binding, clear the submenu stack, and discard the saved pre-open focus. For the shared-panel handoff - when a sibling trigger claims the still-visible panel, the losing core must stand down silently; a syncOpenState(false) would yank focus out of the menu the new owner just opened.

syncOpenState#void
syncOpenState(open: boolean)

Drive from the directive's isOpen effect (inside untracked).

@paramopenboolean