From 9d6bc344e66205924e841600487eab2b2c113b64 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Sun, 26 Jun 2022 20:26:27 +0530 Subject: [PATCH] fix collection search --- .../Search/SearchBar/searchInput/index.tsx | 2 +- src/pages/gallery/index.tsx | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Search/SearchBar/searchInput/index.tsx b/src/components/Search/SearchBar/searchInput/index.tsx index 875ae2970..3c4eb10ff 100644 --- a/src/components/Search/SearchBar/searchInput/index.tsx +++ b/src/components/Search/SearchBar/searchInput/index.tsx @@ -75,7 +75,7 @@ export default function SearchInput(props: Iprops) { props.setOpen(true); break; case SuggestionType.COLLECTION: - props.setActiveCollection(selectedOption.value as number); + search = { collection: selectedOption.value as number }; setValue(null); break; case SuggestionType.IMAGE: diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 659c66a07..bacc71747 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -521,10 +521,15 @@ export default function Gallery() { }; const updateSearch: UpdateSearch = (newSearch, summary) => { - setActiveCollection(ALL_SECTION); - setSearch(newSearch); - setSetSearchResultSummary(summary); - setIsInSearchMode(!!newSearch); + if (newSearch?.collection) { + setActiveCollection(newSearch?.collection); + } else { + setSearch(newSearch); + setSetSearchResultSummary(summary); + } + if (!newSearch?.collection && !search?.file) { + setIsInSearchMode(!!newSearch); + } }; const closeCollectionSelector = (closeBtnClick?: boolean) => {