From 1c5b2715b86dfd1e064e98614d1d7980edacdeb0 Mon Sep 17 00:00:00 2001 From: Anso Date: Mon, 22 Jun 2026 19:37:01 -0400 Subject: [PATCH] fix(editor): suppress global hotkeys while the code editor is focused (#1413) Typing a single-key shortcut (a/h/u/p/b) in the compose editor opened that shortcut's action instead of inserting the character, but only in Chrome. The shared isInputFocused() guard recognized inputs, textareas, and contentEditable elements; in Chromium the Monaco editor uses the EditContext API whose focused surface is a plain focusable div, so the guard missed it and the hotkey handlers fired. Safari falls back to a hidden textarea, which the guard already caught. Match any focus inside the .monaco-editor container so the guard covers the EditContext surface, bringing Chrome to parity with Safari for both global hotkey systems. Add a unit test for the guard. Closes #1410 --- .../src/lib/__tests__/keyboard-guards.test.ts | 87 +++++++++++++++++++ frontend/src/lib/keyboard-guards.ts | 6 +- 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 frontend/src/lib/__tests__/keyboard-guards.test.ts diff --git a/frontend/src/lib/__tests__/keyboard-guards.test.ts b/frontend/src/lib/__tests__/keyboard-guards.test.ts new file mode 100644 index 00000000..b4a5a30f --- /dev/null +++ b/frontend/src/lib/__tests__/keyboard-guards.test.ts @@ -0,0 +1,87 @@ +/** + * Unit tests for isInputFocused, the shared guard both global hotkey systems + * use to bail when the user is typing in a field. + * + * Regression guard for #1410: Monaco's Chromium EditContext input surface is a + * plain focusable
inside .monaco-editor, not a + *