From a4e930386d82c4656424ffe2e56d494e2c65edda Mon Sep 17 00:00:00 2001 From: kayashth1 Date: Fri, 28 Feb 2025 22:08:28 +0000 Subject: [PATCH 1/3] added onFocusSearch functionality --- frontend/src/components/MultiSearch.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index 90aab9825..546a64ef7 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -154,6 +154,14 @@ const MultiSearchBar: React.FC = ({ setHighlightedIndex(null) } + const handleFocusSearch = () => { + if (searchQuery.trim().length > 0 && !showSuggestions) { + setShowSuggestions(true) + }else{ + setHighlightedIndex(null) + } +} + const getIconForIndex = (indexName: string) => { switch (indexName) { case 'chapters': @@ -180,6 +188,7 @@ const MultiSearchBar: React.FC = ({ type="text" value={searchQuery} onChange={handleSearchChange} + onFocus={handleFocusSearch} placeholder={placeholder} className="h-12 w-full rounded-lg border border-gray-300 pl-10 pr-10 text-lg text-black focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white dark:focus:border-blue-300 dark:focus:ring-blue-300" /> From 94bc6d6f86d7a87005ed61dcd746a539f9dacdf8 Mon Sep 17 00:00:00 2001 From: kayashth1 Date: Fri, 28 Feb 2025 23:26:43 +0000 Subject: [PATCH 2/3] check passed --- frontend/src/components/MultiSearch.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index 546a64ef7..dd51ab1c4 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -157,10 +157,10 @@ const MultiSearchBar: React.FC = ({ const handleFocusSearch = () => { if (searchQuery.trim().length > 0 && !showSuggestions) { setShowSuggestions(true) - }else{ - setHighlightedIndex(null) + } else { + setHighlightedIndex(null) + } } -} const getIconForIndex = (indexName: string) => { switch (indexName) { From 5b5f8c4b2690f90750781c14140919cad1d1a6d8 Mon Sep 17 00:00:00 2001 From: kayashth1 Date: Sat, 1 Mar 2025 22:18:38 +0000 Subject: [PATCH 3/3] made suggested changes --- frontend/src/components/MultiSearch.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/components/MultiSearch.tsx b/frontend/src/components/MultiSearch.tsx index dd51ab1c4..f5969f118 100644 --- a/frontend/src/components/MultiSearch.tsx +++ b/frontend/src/components/MultiSearch.tsx @@ -33,6 +33,7 @@ const MultiSearchBar: React.FC = ({ const pageCount = 1 const suggestionCount = 3 const searchBarRef = useRef(null) + const inputRef = useRef(null) const debouncedSearch = useMemo( () => @@ -87,6 +88,7 @@ const MultiSearchBar: React.FC = ({ const handleKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape') { setShowSuggestions(false) + inputRef.current?.blur() } else if (event.key === 'Enter' && highlightedIndex !== null) { const { index, subIndex } = highlightedIndex const suggestion = suggestions[index].hits[subIndex] @@ -187,6 +189,7 @@ const MultiSearchBar: React.FC = ({