diff --git a/app/hooks/cost-surface/index.ts b/app/hooks/cost-surface/index.ts index ceaffa034f..27a4b6827a 100644 --- a/app/hooks/cost-surface/index.ts +++ b/app/hooks/cost-surface/index.ts @@ -16,7 +16,7 @@ export function useProjectCostSurfaces( const { data: session } = useSession(); return useQuery({ - queryKey: ['cost-surfaces', pid], + queryKey: ['cost-surfaces', pid, params], queryFn: async () => JSONAPI.request<{ data: CostSurface[] }>({ method: 'GET', diff --git a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx index 02dcdf7f7b..8cc6bc1e2e 100644 --- a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/index.tsx @@ -157,6 +157,12 @@ const InventoryPanelCostSurface = ({ noData: noDataMessage }: { noData: string } isVisibleOnMap: visibleCostSurface === cs.id, })); + useEffect(() => { + if (allProjectCostSurfacesQuery.isRefetching) { + setSelectedCostSurfaceIds([]); + } + }, [allProjectCostSurfacesQuery.isRefetching]); + return (
diff --git a/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx b/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx index 59d0e152e2..fafa53a26b 100644 --- a/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx @@ -72,10 +72,6 @@ const InventoryPanelProtectedAreas = ({ } }, []); - useEffect(() => { - setSelectedWDPAIds([]); - }, [search]); - const toggleSeeOnMap = useCallback( (WDPAId: WDPA['id']) => { const newSelectedWDPAs = [...visibleWDPAs]; @@ -122,6 +118,12 @@ const InventoryPanelProtectedAreas = ({ isVisibleOnMap: layerSettings[wdpa.id]?.visibility ?? false, })); + useEffect(() => { + if (allProjectWDPAsQuery.isRefetching) { + setSelectedWDPAIds([]); + } + }, [allProjectWDPAsQuery.isRefetching]); + return (