Skip to content
Halorav0.1.0

Behaviors

Dialog behavior

Focus restore, backdrop click, and deep links on top of the native dialog.

Usage#

JavaScript
import { initDialogs, openDialog, closeDialog } from '@originlabsbr/halora/dialog';

const stop = initDialogs({ hash: true });   // data-ha-dialog-open / close, backdrop, hash
NameSignatureDescription
initDialogs({ root?, selector?, hash? }) => destroyWire all dialogs under root. With hash true, #id opens a dialog on load and on hashchange.
openDialog(dialog, { trigger?, hash? }) => voidCall showModal, or set the open attribute without it. Remembers the trigger.
closeDialog(dialog, { hash? }) => voidClose. The close event restores focus and clears the hash.
isBackdropClick(event, dialog) => booleanTrue when the click targets the dialog and lands outside its box.
idFromHash(hash) => string"#cv" to "cv".

Backdrop detection compares the click position with the dialog rectangle, so a click on empty space inside the dialog does not close it. Escape is handled by the browser.

See the Dialog component for markup.

Edit this page on GitHub

Type to search.