mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-09-04 14:45:41 +00:00
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
This commit is contained in:
@@ -2,7 +2,11 @@ export function isInputFocused(): boolean {
|
||||
const el = document.activeElement as HTMLElement | null;
|
||||
if (!el) return false;
|
||||
const tag = el.tagName;
|
||||
return tag === 'INPUT' || tag === 'TEXTAREA' || el.isContentEditable;
|
||||
if (tag === 'INPUT' || tag === 'TEXTAREA' || el.isContentEditable) return true;
|
||||
// Monaco's EditContext surface (Chromium) is a plain focusable <div>, not a textarea or
|
||||
// contentEditable element, so the checks above miss it. Treat any focus inside the editor
|
||||
// container as input focus, matching the textarea fallback other browsers already get.
|
||||
return !!el.closest('.monaco-editor');
|
||||
}
|
||||
|
||||
export function isPaletteOpen(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user