From 3e3a30f510cf6a79e39e3641d61869cf61bc74f5 Mon Sep 17 00:00:00 2001 From: jacob-buster Date: Mon, 22 Sep 2025 17:07:48 -0600 Subject: [PATCH] Fixing copy behavior --- .../ChatLayout/ChatContent/ChatUserMessage.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx b/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx index 29801f10b..760de96aa 100644 --- a/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx +++ b/apps/web/src/layouts/ChatLayout/ChatContent/ChatUserMessage.tsx @@ -36,8 +36,19 @@ export const ChatUserMessage: React.FC<{ const handleCopy = useCallback( (e?: React.ClipboardEvent) => { - // Prevent default copy behavior - //I do not know why this is needed, but it is... + // Check if user has selected text + const selection = window.getSelection(); + const hasSelection = selection && selection.toString().length > 0; + + // If user has selected text, let browser handle it naturally + if (hasSelection && e?.clipboardData) { + // Don't prevent default - let browser copy the selected text + return; + } + + // Only override copy behavior when no text is selected + // This handles the case where user presses Ctrl+C without selection + // or when the copy button is clicked if (e?.clipboardData) { e.preventDefault(); e.clipboardData.setData('text/plain', request || '');