From 032f2246e45e9a5ef61d233ca3cafec8bd6f8b99 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Nov 2025 22:28:21 +0000 Subject: [PATCH] fix: permettre les espaces dans les titres des notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le hook useKeyboardShortcuts interceptait tous les événements clavier, y compris dans les champs de saisie, empêchant la saisie d'espaces. La correction ignore les raccourcis sans modificateur quand l'utilisateur tape dans un input, textarea ou contentEditable, tout en permettant les raccourcis avec Ctrl/Alt/Meta de fonctionner normalement. --- src/hooks/useKeyboardShortcuts.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/hooks/useKeyboardShortcuts.ts b/src/hooks/useKeyboardShortcuts.ts index 89032a4..c7970d4 100644 --- a/src/hooks/useKeyboardShortcuts.ts +++ b/src/hooks/useKeyboardShortcuts.ts @@ -22,6 +22,13 @@ export function useKeyboardShortcuts( if (!enabled) return; const handleKeyDown = (event: KeyboardEvent) => { + // Ignore keyboard shortcuts when typing in input fields, textareas, or contentEditable elements + // UNLESS the shortcut has a modifier key (Ctrl, Alt, Meta) + const target = event.target as HTMLElement; + const isInputField = target.tagName === 'INPUT' || + target.tagName === 'TEXTAREA' || + target.isContentEditable; + for (const shortcut of shortcuts) { const keyMatch = event.key.toLowerCase() === shortcut.key.toLowerCase(); const ctrlMatch = shortcut.ctrl ? (event.ctrlKey || event.metaKey) : !event.ctrlKey && !event.metaKey; @@ -30,6 +37,12 @@ export function useKeyboardShortcuts( const metaMatch = shortcut.meta ? event.metaKey : !event.metaKey; if (keyMatch && ctrlMatch && altMatch && shiftMatch && metaMatch) { + // Skip shortcuts without modifiers when user is typing in input fields + const hasModifier = shortcut.ctrl || shortcut.alt || shortcut.meta; + if (isInputField && !hasModifier) { + continue; + } + if (shortcut.preventDefault !== false) { event.preventDefault(); }