GuideCoreUpdated in v15

Overlay

Style ngwr's floating panels and control where focus goes.

Scope styles to ngwr overlays

ngwr's overlays render into their own .wr-overlay-container; no provider needed.

.wr-overlay-container .cdk-overlay-pane {
  font-size: var(--wr-text-sm);
}
  • A z-index does not reach an overlay: CDK renders overlays in the top layer.
  • To open your own panel in ngwr's container, inject WR_OVERLAY from ngwr/overlay, not CDK's Overlay.

Focus, on the way in

WrDialog, <wr-drawer> and WrDrawerManager trap focus and move it inside, to the first match below.

  1. The element with cdkFocusInitial. A plain attribute, nothing to import.
  2. The first tabbable element.
  3. Nothing: focus stays put, and the trap still holds.

In <wr-drawer> the first tabbable is the ✕; set cdkFocusInitial to choose another.

<h2 wrDialogTitle>Delete project</h2>
<p>This cannot be undone.</p>

<footer>
  <button wr-btn type="button" cdkFocusInitial [wrDialogClose]="false">Cancel</button>
  <button wr-btn type="button" color="danger" [wrDialogClose]="true">Delete</button>
</footer>

Focus, on the way out

Every way of closing returns focus to the element that opened the overlay.

Closed byTurn off with
EscapecloseOnEscape: false
The built-in ✕closable: false
Backdrop clickcloseOnBackdropClick: false
A route changecloseOnNavigation: false
[wrDialogClose] / ref.close(result)—

A dismissal resolves awaitClose() with undefined, like close(); close with a value to tell them apart.

Dependencies

See also