diff --git a/client/src/components/Chat/Header.tsx b/client/src/components/Chat/Header.tsx index 4f491f4b05..0390eb428d 100644 --- a/client/src/components/Chat/Header.tsx +++ b/client/src/components/Chat/Header.tsx @@ -36,7 +36,7 @@ export default function Header() { return (
-
+
{!navVisible && } {!navVisible && } {} diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx index 3e4e4f6983..7ac983099f 100644 --- a/client/src/components/Chat/Input/ChatForm.tsx +++ b/client/src/components/Chat/Input/ChatForm.tsx @@ -151,12 +151,6 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => { const textValue = useWatch({ control: methods.control, name: 'text' }); - useEffect(() => { - if (!search.isSearching && textAreaRef.current && !disableInputs) { - textAreaRef.current.focus(); - } - }, [search.isSearching, disableInputs]); - useEffect(() => { if (textAreaRef.current) { const style = window.getComputedStyle(textAreaRef.current); diff --git a/client/src/components/Conversations/Conversations.tsx b/client/src/components/Conversations/Conversations.tsx index eea39eaed6..a0bf03e49d 100644 --- a/client/src/components/Conversations/Conversations.tsx +++ b/client/src/components/Conversations/Conversations.tsx @@ -220,6 +220,7 @@ const Conversations: FC = ({ role="list" aria-label="Conversations" onRowsRendered={handleRowsRendered} + tabIndex={-1} /> )} diff --git a/client/src/components/Nav/SearchBar.tsx b/client/src/components/Nav/SearchBar.tsx index 9e21b52663..9fc271577a 100644 --- a/client/src/components/Nav/SearchBar.tsx +++ b/client/src/components/Nav/SearchBar.tsx @@ -1,7 +1,7 @@ -import { forwardRef, useState, useCallback, useMemo, useEffect, Ref } from 'react'; +import React, { forwardRef, useState, useCallback, useMemo, useEffect, useRef } from 'react'; import debounce from 'lodash/debounce'; +import { useRecoilState } from 'recoil'; import { Search, X } from 'lucide-react'; -import { useSetRecoilState, useRecoilValue } from 'recoil'; import { QueryKeys } from 'librechat-data-provider'; import { useQueryClient } from '@tanstack/react-query'; import { useLocation, useNavigate } from 'react-router-dom'; @@ -13,7 +13,7 @@ type SearchBarProps = { isSmallScreen?: boolean; }; -const SearchBar = forwardRef((props: SearchBarProps, ref: Ref) => { +const SearchBar = forwardRef((props: SearchBarProps, ref: React.Ref) => { const localize = useLocalize(); const location = useLocation(); const queryClient = useQueryClient(); @@ -21,11 +21,11 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: Ref) = const { isSmallScreen } = props; const [text, setText] = useState(''); + const inputRef = useRef(null); const [showClearIcon, setShowClearIcon] = useState(false); const { newConversation } = useNewConvo(); - const setSearchState = useSetRecoilState(store.search); - const search = useRecoilValue(store.search); + const [search, setSearchState] = useRecoilState(store.search); const clearSearch = useCallback(() => { if (location.pathname.includes('/search')) { @@ -44,6 +44,7 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: Ref) = isTyping: false, })); clearSearch(); + inputRef.current?.focus(); }, [setSearchState, clearSearch]); const handleKeyUp = (e: React.KeyboardEvent) => { @@ -108,6 +109,7 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: Ref) = ) = autoComplete="off" dir="auto" /> - + tabIndex={showClearIcon ? 0 : -1} + disabled={!showClearIcon} + > + +
); });