mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 11:11:20 -08:00
refactor(core): [CORE-23] complete keyboard controls and focus lifecycle
This commit is contained in:
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 })
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user