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:
1 parent
d1b26e625a
commit
bbfe968ff1
3 files changed
+18
-3
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user