fix: detect typing inside the QuotedHtml shadow island via composedPath #654

This commit is contained in:
Linus Rath
2026-07-21 23:26:51 +02:00
parent 4ad9267a2d
commit a909593dda
6 changed files with 120 additions and 37 deletions
+2 -9
View File
@@ -8,6 +8,7 @@
// The listener ignores events when an editable element has focus, matching
// the convention in `use-keyboard-shortcuts.ts`.
import { isEditableEventTarget } from '@/lib/keyboard';
import type { SandboxInstance } from './host-bridge';
interface Binding {
@@ -62,16 +63,8 @@ function eventMatches(ev: KeyboardEvent, combo: NormalisedCombo): boolean {
return ev.key.toLowerCase() === combo.key;
}
function isEditableTarget(target: EventTarget | null): boolean {
if (!(target instanceof HTMLElement)) return false;
const tag = target.tagName.toLowerCase();
if (tag === 'input' || tag === 'textarea' || tag === 'select') return true;
if (target.isContentEditable) return true;
return false;
}
function onKeyDown(ev: KeyboardEvent): void {
if (isEditableTarget(ev.target)) return;
if (isEditableEventTarget(ev)) return;
if (bindings.size === 0) return;
for (const binding of bindings.values()) {
const combo = normaliseCombo(binding.keys);