From 7c9a6398d4a953c94f9e0a76cb16748b1375cde5 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Thu, 12 Mar 2026 23:15:08 -0700 Subject: [PATCH] dialog: support nesting/stacking & improve ergonomics - stacked/nested dialogs work properly - dialog api expanded to include `hasError` and `focus` - `onopenchange` prop added, `onopen` and `onclose` deprecated - improve accessibility with additional aria props --- src/lib/Dialog.svelte | 93 ++++++++++++++++++++++++++++++++++------- src/routes/+page.svelte | 13 ++++-- 2 files changed, 87 insertions(+), 19 deletions(-) diff --git a/src/lib/Dialog.svelte b/src/lib/Dialog.svelte index 14d6a15..35ae46e 100644 --- a/src/lib/Dialog.svelte +++ b/src/lib/Dialog.svelte @@ -5,6 +5,8 @@ export interface DialogAPI { /** shows an error message at the top of the dialog */ error: (message: RawError | null) => void; + /** Returns if the dialog is displaying an error */ + hasError: () => boolean; /** closes the dialog */ close: () => void; /** opens the dialog */ @@ -39,6 +41,8 @@ * changes made via this API will NOT propagate to consuming components. */ title: (title: string) => void; + /** Focuses the dialog */ + focus: () => void; } type DialogControlButton = { @@ -79,6 +83,9 @@ }; export { dialogCancelButton, dialogOkButton, dialogCloseButton }; + + /** stack of currently open dialogs by identifier */ + let dialogStack: DialogAPI[] = $state([]);