fix-ignore-editor-hotkeys-in-inputs

This commit is contained in:
clawdbot 2026-01-29 07:24:48 +08:00
parent b252a80a8e
commit 3ea6aa8fb3

View File

@ -21,15 +21,16 @@ export function bindEditorHotkeys(getShift: () => boolean, dispatch: (a: EditorA
const onKeyDown = (e: KeyboardEvent) => { const onKeyDown = (e: KeyboardEvent) => {
const ctrl = e.ctrlKey || e.metaKey; const ctrl = e.ctrlKey || e.metaKey;
// Do not steal common hotkeys while typing in an input/editor.
// (Including Escape: inputs often use it to revert/blur.)
if (isEditableTarget(e.target)) return;
// Esc: clear selection (and closes context menu via selection parity effect). // Esc: clear selection (and closes context menu via selection parity effect).
if (e.key === 'Escape') { if (e.key === 'Escape') {
dispatch({ type: 'selectSingle', id: undefined }); dispatch({ type: 'selectSingle', id: undefined });
return; return;
} }
// Do not steal common hotkeys while typing in an input/editor.
if (isEditableTarget(e.target)) return;
// Undo/redo // Undo/redo
if (ctrl && e.key.toLowerCase() === 'z') { if (ctrl && e.key.toLowerCase() === 'z') {
e.preventDefault(); e.preventDefault();