From e0170aedd62f1d71222af451c56ee56d70ff2c7b Mon Sep 17 00:00:00 2001 From: Gomathi9520 Date: Thu, 10 Apr 2025 09:52:27 +0530 Subject: [PATCH] Fix: event listener interference with input typing --- app/src/utils/shortcutkeys/handleShortcutKeys.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/utils/shortcutkeys/handleShortcutKeys.ts b/app/src/utils/shortcutkeys/handleShortcutKeys.ts index e3c484b..57fdf66 100644 --- a/app/src/utils/shortcutkeys/handleShortcutKeys.ts +++ b/app/src/utils/shortcutkeys/handleShortcutKeys.ts @@ -55,9 +55,21 @@ const KeyPressListener: React.FC = () => { useEffect(() => { // Function to handle keydown events const handleKeyPress = (event: KeyboardEvent) => { - // Allow default behavior for F5 and F12 - const keyCombination = detectModifierKeys(event); + const activeElement = document.activeElement; + + const isTyping = + activeElement instanceof HTMLInputElement || + activeElement instanceof HTMLTextAreaElement || + (activeElement && activeElement.getAttribute('contenteditable') === 'true'); + + if (isTyping) { + return; // Don't trigger shortcuts while typing + } + + const keyCombination = detectModifierKeys(event); + + // Allow default behavior for F5 and F12 if (["F5", "F11", "F12"].includes(event.key) || keyCombination === "Ctrl+R") { return; }