Skip to content

Commit 2a00c09

Browse files
committed
fix(keyboard): prevent duplicate modifier shortcut handling in CodeMirror
1 parent c452f15 commit 2a00c09

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/handlers/keyboard.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ export default function keyboardHandler(e) {
6464
if (!ctrlKey && !shiftKey && !altKey && !metaKey) return;
6565
if (["Control", "Alt", "Meta", "Shift"].includes(key)) return;
6666

67+
const target = editorManager?.editor?.contentDOM;
68+
if (!target) return;
69+
70+
// Physical keyboard events already reaching CodeMirror should not be
71+
// re-dispatched from the document listener.
72+
if ($target === target || (target.contains?.($target) ?? false)) return;
73+
6774
const event = KeyboardEvent("keydown", {
6875
key,
6976
ctrlKey,
7077
shiftKey,
7178
altKey,
7279
metaKey,
7380
});
74-
const target = editorManager?.editor?.contentDOM;
7581
target?.dispatchEvent?.(event);
7682
}
7783

0 commit comments

Comments
 (0)