Merge pull request #32973 from johnphilip283/search-on-first-navigate

perform search on first navigate
This commit is contained in:
Fredrik Adelöw
2026-02-24 09:41:47 +01:00
committed by GitHub
4 changed files with 9 additions and 5 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-search-react': patch
'@backstage/plugin-search': patch
---
Fixes the search component not registering the first search on navigate to the search page.
+1
View File
@@ -0,0 +1 @@
Fixes the search component to register the first search that happens on initial navigation to the search page.
@@ -138,14 +138,13 @@ const useSearchContextValue = (
const result = useAsync(async (): Promise<SearchResultSet> => {
if (isFirstEmptyMount.current) {
isFirstEmptyMount.current = false;
if (!term && !types.length && !Object.keys(filters).length) {
return {
results: [],
numberOfResults: 0,
};
}
isFirstEmptyMount.current = false;
}
// Here we cancel the previous request before making a new one
@@ -59,9 +59,7 @@ export const UrlUpdater = () => {
setPageCursor(query.pageCursor as string);
}
if (query.types) {
setTypes(query.types as string[]);
}
setTypes(query.types ? (query.types as string[]) : []);
}, [prevQueryParams, location, setTerm, setTypes, setPageCursor, setFilters]);
useEffect(() => {