feat(ui): harden modal dialogs, add afterModalsClosed
Re-show a natively closed dialog only when its consumer answered 'kept'; returnFocus; ignore a held Escape; Dialog honours reduced motion; useBeforeUnload extracted; focusRow reports found only when the row holds focus.
This commit is contained in:
1 parent
36c6eb3fea
commit
553a0e57b2
6 files changed
+336
-30
No files matched your search
@@ -82,7 +82,7 @@ export function visibleElement(
|
||||
)
|
||||
}
|
||||
|
||||
/** Scrolls to and focuses the visible row tagged with `key`; false when there is none. */
|
||||
/** Scrolls to and focuses the visible row tagged with `key`; false unless the row now holds the focus. */
|
||||
export function focusRow(key: ElementKey): boolean {
|
||||
const wanted = JSON.stringify(key)
|
||||
const row = [
|
||||
@@ -94,7 +94,7 @@ export function focusRow(key: ElementKey): boolean {
|
||||
if (!row) return false
|
||||
row.scrollIntoView?.({ block: 'center' })
|
||||
row.focus()
|
||||
return true
|
||||
return document.activeElement === row
|
||||
}
|
||||
|
||||
/** Row-based places (Général, Vues, Catégories, Régions): focus the named row. */
|
||||
@@ -150,8 +150,8 @@ function activeTabButton(): HTMLElement | null {
|
||||
}
|
||||
|
||||
/** Gives the focus to the shown tab's button: a lost focus must not leave on `body`. */
|
||||
export function focusActiveTab(): void {
|
||||
activeTabButton()?.focus()
|
||||
export function focusActiveTab(options?: FocusOptions): void {
|
||||
activeTabButton()?.focus(options)
|
||||
}
|
||||
|
||||
/** The element holding the focus, when it is something other than `body`. */
|
||||
|
||||
Reference in new issue
Block a user