refactor(core): [CORE-23] complete keyboard controls and focus lifecycle

This commit is contained in:
Harvey Zhao committed 2026-09-11 21:06:33 +08:00
1 parent faaa3e8c2d
commit 8ed0a5228c
190 files changed
+53981 -489

No files matched your search

@@ -0,0 +1,9 @@
/** Restore the same focused descendant after DOM reparenting. */
export function captureMovedFocus(root: HTMLElement): () => void {
const focused = root.ownerDocument?.activeElement as HTMLElement | null | undefined
const inside = focused && root.contains(focused)
return () => {
if (inside && focused.isConnected && root.contains(focused) && focused.ownerDocument.activeElement === focused.ownerDocument.body)
focused.focus({ preventScroll: true })
}
}