API reference
Context Menu composes menu primitives with a dedicated trigger directive for right-click and keyboard context invocation. The exported tngContextMenu instance also exposes anchor state so owners can choose their own placement strategy.
Wrapper APIs
| Element / Directive | Input / Output | Type | Description |
|---|---|---|---|
<tng-context-menu> | ariaLabel | string | Accessible label for the context panel. |
<tng-context-menu> | loop, disabled, closeOnSelect | boolean | Forwards core menu traversal, disable state, and select-close behavior. |
<tng-context-menu> | dismissOnOutsideClick, dismissOnFocusout | boolean | Dismiss policy applied to the hosted menu panel. |
<tng-context-menu> | tngMenuOpened, tngMenuClosed, tngMenuSelect | EventEmitter | Lifecycle and selection outputs from the underlying menu primitive. |
[tngContextMenuTrigger] | tngContextMenuTrigger | TngContextMenu | Binds a target element to a context-menu instance. |
Primitive directives
| Directive | Purpose | Notes |
|---|---|---|
tngContextMenu | Connects context trigger semantics to a menu panel host. | Applied together with tngMenu on the menu surface. |
tngContextMenuTrigger | Listens for contextmenu, Shift + F10, and ContextMenu. | Sets data-slot="context-menu-trigger", aria-haspopup, aria-controls, and aria-expanded. |
tngMenu, tngMenuItem | Menu state, keyboard traversal, selection, submenu composition. | Shared primitive contract with menu and menubar docs. |
Exported Instance
| Method | Type | Description |
|---|---|---|
isOpen() | boolean | Current open state for the linked context menu. |
close(restoreFocus) | (restoreFocus: boolean) => void | Closes the panel and optionally restores focus to the trigger target. |
getAnchorType() | 'pointer' | 'element' | null | Tells whether the current open came from right-click coordinates or keyboard context invocation. |
getPointerAnchor() | TngContextMenuPointerAnchor | null | Viewport client coordinates captured during right-click open. Returns null for keyboard opens. |
Keyboard contract (high level)
Shift + F10orContextMenuopens for focused target.ArrowDown/ArrowUpmoves active action.Home/Endjumps to first and last enabled actions.Enter/Spaceactivates highlighted action.Escapecloses the active context panel and restores trigger focus.