fix(editor): Task 2 review round 1, trace calls, form hooks, keyboard proof

This commit is contained in:
bchanot committed 2026-11-13 19:39:29 +01:00
1 parent c893dec60b
commit b703333b20
15 files changed
+476 -261

No files matched your search

+13 -1
View File
@@ -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
}
/**