fix: suppress shortcuts when typing in input fields

Shortcut dispatcher now skips non-modifier keys when focus is in an
editable field. Editor find bar ESC stops propagation to close bar
before modal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
thandClaude Opus 4.6 committed 2026-04-12 12:57:05 +02:00
1 parent d1b26e625a
commit bbfe968ff1
3 files changed
+18 -3

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
define('APP_NAME', 'hyprcrd'); define('APP_NAME', 'hyprcrd');
define('APP_VERSION', '1.0.0'); define('APP_VERSION', '1.0.1');
// Database path — writable directory, outside webroot // Database path — writable directory, outside webroot
define('DB_PATH', __DIR__ . '/data/hyprcrd.db'); define('DB_PATH', __DIR__ . '/data/hyprcrd.db');
+2 -2
View File
@@ -1080,11 +1080,11 @@ function replaceAll() {
findInput?.addEventListener('input', runFind); findInput?.addEventListener('input', runFind);
findInput?.addEventListener('keydown', e => { findInput?.addEventListener('keydown', e => {
if (e.key === 'Enter') { e.preventDefault(); e.shiftKey ? findPrev() : findNext(); } 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 => { replInput?.addEventListener('keydown', e => {
if (e.key === 'Enter') { e.preventDefault(); replaceOne(); } 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-next')?.addEventListener('click', findNext);
$('find-prev')?.addEventListener('click', findPrev); $('find-prev')?.addEventListener('click', findPrev);
+15
View File
@@ -87,7 +87,18 @@ export const guards = {
// ── Dispatcher ── // ── 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) => { document.addEventListener('keydown', (e) => {
const inEditable = isEditableTarget();
for (const s of registry) { for (const s of registry) {
// Key match // Key match
let matched; let matched;
@@ -102,6 +113,10 @@ document.addEventListener('keydown', (e) => {
} }
if (!matched) continue; 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 // Guard
if (s.guard && !s.guard()) continue; if (s.guard && !s.guard()) continue;