Skip to main content
cngx-src documentation

CngxOverlayRef

ClassPrimaryv0.1.0WCAG AA

projects/ui/overlay/overlay-ref.ts

Import#

import { CngxOverlayRef } from '@cngx/ui/overlay'

Description#

Typed wrapper around a CDK OverlayRef that exposes a close result stream.

Closes on Escape and on a backdrop click (unless disableClose), restores focus to the element that opened it, and surfaces its open state as a signal beside the RxJS afterClosed$.

Dependencies#

CdkOverlayRefconstructor

Index#

Instance Properties#

afterClosed$#unknown
Readonly

Emits once with the close result when the overlay is dismissed, then completes.

this._afterClosed.asObservable()
isOpen#Signal
Readonly

true while the overlay is open, false once closed. The signal view of the lifecycle beside afterClosed$ - bind it in a template without an async pipe.

this.openState.asReadonly()

Methods#

close#void
close(result?: R)

Closes the overlay, emitting result on afterClosed$, disposing the CDK ref, and restoring focus. Idempotent - a second call (e.g. Escape after a scope teardown already closed it) is a no-op.

@paramresult?R