diff --git a/client/src/components/Nav/NewChat.tsx b/client/src/components/Nav/NewChat.tsx index 4f4f64c44f..af33799166 100644 --- a/client/src/components/Nav/NewChat.tsx +++ b/client/src/components/Nav/NewChat.tsx @@ -1,5 +1,5 @@ import React, { useCallback } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { Link } from 'react-router-dom'; import { QueryKeys } from 'librechat-data-provider'; import { useQueryClient } from '@tanstack/react-query'; import { TooltipAnchor, NewChatIcon, MobileSidebar, Sidebar, Button } from '@librechat/client'; @@ -24,7 +24,6 @@ export default function NewChat({ const queryClient = useQueryClient(); /** Note: this component needs an explicit index passed if using more than one */ const { newConversation: newConvo } = useNewConvo(index); - const navigate = useNavigate(); const localize = useLocalize(); const { conversation } = store.useCreateConversationAtom(index); @@ -36,21 +35,22 @@ export default function NewChat({ }, 250); }, [toggleNav]); - const clickHandler: React.MouseEventHandler = useCallback( + const clickHandler: React.MouseEventHandler = useCallback( (e) => { - if (e.button === 0 && (e.ctrlKey || e.metaKey)) { - window.open('/c/new', '_blank'); + // Let browser handle modified/non-left clicks (new tab, context menu, etc.) + if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; } + + e.preventDefault(); clearMessagesCache(queryClient, conversation?.conversationId); queryClient.invalidateQueries([QueryKeys.messages]); newConvo(); - navigate('/c/new', { state: { focusChat: true } }); if (isSmallScreen) { toggleNav(); } }, - [queryClient, conversation, newConvo, navigate, toggleNav, isSmallScreen], + [queryClient, conversation, newConvo, toggleNav, isSmallScreen], ); return ( @@ -84,14 +84,16 @@ export default function NewChat({ description={localize('com_ui_new_chat')} render={ } />