From da6c82929663478d409abb8894d4beb392d89b27 Mon Sep 17 00:00:00 2001 From: the1812 Date: Fri, 28 Feb 2025 08:53:42 +0800 Subject: [PATCH] Fix video focus for Firefox (fix #5153) --- registry/lib/components/utils/keymap/bindings.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/registry/lib/components/utils/keymap/bindings.ts b/registry/lib/components/utils/keymap/bindings.ts index 113bb6c0c..e8a8f40c2 100644 --- a/registry/lib/components/utils/keymap/bindings.ts +++ b/registry/lib/components/utils/keymap/bindings.ts @@ -46,9 +46,16 @@ export const loadKeyBindings = lodash.once((bindings: KeyBinding[]) => { } // 忽略其他可聚焦元素 - const hasElementFocus = !([document.body, null] as (Element | null)[]).includes( - getActiveElement(), - ) + const hasElementFocus = (() => { + const activeElement = getActiveElement() + if (([document.body, null] as (Element | null)[]).includes(activeElement)) { + return false + } + if (activeElement instanceof HTMLMediaElement) { + return false + } + return true + })() if ( (binding.action.ignoreFocus !== false || binding.action.ignoreTyping !== false) && hasElementFocus