fix(editor): Task 2 review round 1, trace calls, form hooks, keyboard proof
This commit is contained in:
1 parent
c893dec60b
commit
b703333b20
15 files changed
+476
-261
No files matched your search
@@ -211,7 +211,19 @@ export function refocusIfHidden(
|
||||
if (!gone && document.activeElement === held) return
|
||||
const homeShown = home?.isConnected && !home.closest('[hidden]')
|
||||
if (homeShown) home.focus()
|
||||
if (!homeShown || document.activeElement !== home) focusActiveTab()
|
||||
if (homeShown && document.activeElement === home) return
|
||||
// Under a modal dialog the tab row is inert: the focus stays in the top dialog.
|
||||
if (!focusTopDialog()) focusActiveTab()
|
||||
}
|
||||
|
||||
/** The first control of the top open dialog takes the focus; false when none is open. */
|
||||
function focusTopDialog(): boolean {
|
||||
const top = [...document.querySelectorAll<HTMLElement>('dialog[open]')].at(-1)
|
||||
const control = top?.querySelector<HTMLElement>(
|
||||
'button:not([disabled]), input:not([disabled]), select, textarea, a[href]',
|
||||
)
|
||||
control?.focus()
|
||||
return control !== undefined && document.activeElement === control
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user