From 30e5c8d931bb75d78928e6ae0d354216e67511d7 Mon Sep 17 00:00:00 2001 From: andupetcu <47487320+andupetcu@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:21:56 +0300 Subject: [PATCH] Fix keyboard shortcuts conflict between bible reader and AI chat - Added data-floating-chat attribute to chat component for easy detection - Updated bible reader keyboard event handler to check if chat is open - Prevent shortcuts from triggering when user is typing in input fields - Check for dialogs, modals, and the floating chat before processing shortcuts --- app/[locale]/bible/reader.tsx | 17 +++++++++++++++++ components/chat/floating-chat.tsx | 1 + 2 files changed, 18 insertions(+) diff --git a/app/[locale]/bible/reader.tsx b/app/[locale]/bible/reader.tsx index 46fa94a..a7580a6 100644 --- a/app/[locale]/bible/reader.tsx +++ b/app/[locale]/bible/reader.tsx @@ -298,6 +298,23 @@ export default function BibleReaderNew() { // Keyboard shortcuts useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { + // Don't trigger shortcuts if user is typing in an input field + const activeElement = document.activeElement as HTMLElement + if (activeElement && ( + activeElement.tagName === 'INPUT' || + activeElement.tagName === 'TEXTAREA' || + activeElement.isContentEditable || + activeElement.closest('[role="dialog"]') // Don't trigger if a dialog/modal is open + )) { + return + } + + // Check if the floating chat is open + const floatingChat = document.querySelector('[data-floating-chat="true"]') + if (floatingChat) { + return + } + if (e.ctrlKey || e.metaKey) return switch (e.key) { diff --git a/components/chat/floating-chat.tsx b/components/chat/floating-chat.tsx index 0317285..7acfb18 100644 --- a/components/chat/floating-chat.tsx +++ b/components/chat/floating-chat.tsx @@ -192,6 +192,7 @@ export default function FloatingChat() {