From 779749fbd78b1da4d5ea17dffc0905d85e71a697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 20 May 2026 17:57:33 +0200 Subject: [PATCH] Guard against empty-filter fetch on mount and premature URL sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The lastFetchParamsRef starts as undefined, so the initial debounce would have fetched with an empty filter (returning every entity in the catalog). Guard against this by skipping the fetch when no filter components have registered yet. Also skip the URL sync effect until at least one filter has been set, to avoid briefly clearing filter query params from the URL bar before filter components initialize. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .../catalog-react/src/hooks/useEntityListProvider.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx index a359a8f2bc..c6a35be367 100644 --- a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx +++ b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx @@ -301,6 +301,13 @@ export const EntityListProvider = ( }; } + // No filters registered yet — wait for filter components to + // call updateFilters before making the first request. + if (compacted.length === 0 && lastFetchParamsRef.current === undefined) { + setLoading(false); + return; + } + if (isEqual(fetchParams, lastFetchParamsRef.current)) { return; } @@ -351,7 +358,7 @@ export const EntityListProvider = ( // to replace the state rather than pushing, since we don't want // there to be back/forward slots for every single filter change. useEffect(() => { - if (!isMounted()) { + if (!isMounted() || Object.keys(requestedFilters).length === 0) { return; } const queryParams = Object.keys(requestedFilters).reduce((params, key) => {