diff --git a/config.php b/config.php index 189a4c4..30a2378 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ { if (e.key === 'Enter') { e.preventDefault(); e.shiftKey ? findPrev() : findNext(); } - if (e.key === 'Escape') { e.preventDefault(); closeFindBar(); } + if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeFindBar(); } }); replInput?.addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); replaceOne(); } - if (e.key === 'Escape') { e.preventDefault(); closeFindBar(); } + if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeFindBar(); } }); $('find-next')?.addEventListener('click', findNext); $('find-prev')?.addEventListener('click', findPrev); diff --git a/public/js/modules/shortcuts.js b/public/js/modules/shortcuts.js index 8960543..f0761d8 100644 --- a/public/js/modules/shortcuts.js +++ b/public/js/modules/shortcuts.js @@ -87,7 +87,18 @@ export const guards = { // ── Dispatcher ── +function isEditableTarget() { + const el = document.activeElement; + if (!el) return false; + const tag = el.tagName; + if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return true; + if (el.isContentEditable) return true; + return false; +} + document.addEventListener('keydown', (e) => { + const inEditable = isEditableTarget(); + for (const s of registry) { // Key match let matched; @@ -102,6 +113,10 @@ document.addEventListener('keydown', (e) => { } if (!matched) continue; + // Suppress non-modifier shortcuts when focus is in an editable field + // (except Escape which should always close overlays) + if (inEditable && !s.ctrl && !s.alt && !s.match && e.key !== 'Escape') continue; + // Guard if (s.guard && !s.guard()) continue;