diff --git a/src/aurelia-dialog.ts b/src/aurelia-dialog.ts index 1ade8e1..ab6b6aa 100644 --- a/src/aurelia-dialog.ts +++ b/src/aurelia-dialog.ts @@ -19,6 +19,7 @@ export * from './dialog-settings'; export * from './dialog-configuration'; export * from './renderer'; export * from './dialog-cancel-error'; +export * from './dialog-close-error'; export * from './dialog-result'; export * from './dialog-service'; export * from './dialog-controller'; diff --git a/src/dialog-settings.ts b/src/dialog-settings.ts index 73c6aae..f715e4b 100644 --- a/src/dialog-settings.ts +++ b/src/dialog-settings.ts @@ -92,6 +92,14 @@ export interface DialogSettings { * When invoked the function is passed the dialog container and the dialog overlay elements. */ position?: (dialogContainer: Element, dialogOverlay?: Element) => void; + + /** + * This function is called when a dialog closes to restore focus to the last + * element that was focused when the dialog opened. It can be overridden in + * general settings, or on a case by case basis by providing an override when + * a particular dialog is opened. + */ + restoreFocus?: (lastActiveElement: HTMLElement) => void; } /** @@ -105,4 +113,5 @@ export class DefaultDialogSettings implements DialogSettings { public rejectOnCancel = false; public ignoreTransitions = false; public position?: (dialogContainer: Element, dialogOverlay: Element) => void; + public restoreFocus = (lastActiveElement: HTMLElement) => lastActiveElement.focus(); }