Skip to content

Commit

Permalink
Fix for home collections search with multiple results
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed Sep 7, 2023
1 parent 9451a36 commit 843c381
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
nested structures as single columns in the collection view.
- The collection count value is now updated with filters applied.
- Fix for csv export not working when underlying data is invalid.
- Fix for bug of collection search returning a single result.
- Fix for reference fields breaking with incorrect values.

## [2.0.5] - 2023-07-11

Expand Down
9 changes: 6 additions & 3 deletions lib/src/core/components/HomePage/FireCMSHomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { SearchBar } from "../EntityCollectionTable/internal/SearchBar";
import { FavouritesView } from "./FavouritesView";
import { useRestoreScroll } from "../../internal/useRestoreScroll";

const search = new JsSearch.Search("home");
const search = new JsSearch.Search("url");
search.addIndex("name");
search.addIndex("description");
search.addIndex("group");
Expand Down Expand Up @@ -54,15 +54,18 @@ export function FireCMSHomePage({ additionalChildrenStart, additionalChildrenEnd
: navigationEntries;

useEffect(() => {
search.addDocuments(filteredNavigationEntries);
console.log("Updating search index", navigationEntries);
search.addDocuments(navigationEntries);
}, [navigationEntries]);

const updateSearchResults = useCallback(
(value?: string) => {
if (!value || value === "") {
setFilteredUrls(null);
} else {
setFilteredUrls(search.search(value).map((e: any) => e.url));
const searchResult = search.search(value);
console.log("Search result", searchResult)
setFilteredUrls(searchResult.map((e: any) => e.url));
}
}, []);

Expand Down

0 comments on commit 843c381

Please sign in to comment.