Skip to main content
cngx-src documentation

CngxMenuDismissHandlerOptions

Interface

projects/common/interactive/menu/dismiss-handler.ts

Import#

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

Description#

Options for createMenuDismissHandler.

Each boolean toggles its listener (pair) independently. When dismissOnBlur is true, both window blur and document pointercancel listeners install together - they represent the same "context lost" semantic and consumers who want one rarely want the other off.

Index#

Instance Properties#

dismissOnBlur#boolean
Readonly

Install window blur AND document pointercancel listeners. Bundled together because both signal context loss. pointercancel events whose target lies inside the popover or trigger host are filtered out (in-menu palm rejection must not dismiss).

dismissOnOutsideClick#boolean
Readonly

Install document pointerdown outside-click listener.

dismissOnScroll#boolean
Readonly

Install window scroll listener (capture, passive).

hostElement#HTMLElement
Readonly

Trigger host element. Pointerdown / pointercancel events whose target lies inside this element are NOT treated as dismissal - interactions with the trigger itself should never close the menu it just opened.

onDismiss#function
ReadonlyOptional

Synchronous callback invoked from the DOM event handler whenever a dismissal source fires. Runs AFTER popover.hide() so consumers observing the source see the post-close state. Used by createMenuTriggerDismissBinding to write a reactive lastSource signal from outside any Angular effect() context.

Readonly

Popover whose .hide() runs when any dismissal source fires.

skipSources#ReadonlySet
ReadonlyOptional

Sources whose listeners should NOT install even when their toggle is true. Lets a consumer keep dismissOnBlur: true but skip the bundled pointer-cancel listener (or vice versa) with a one-line factory wrapper:

providers: [{
  provide: CNGX_MENU_DISMISS_HANDLER_FACTORY,
  useValue: (opts) => createMenuDismissHandler({
    ...opts,
    skipSources: new Set(['pointer-cancel']),
  }),
}]

'escape' may be skipped too; the popover's global Escape listener still owns the close path, so skipping only stops the source from being recorded on lastSource.