diff --git a/app/layout/project/sidebar/project/inventory-panel/features/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/index.tsx index 6ba7a9dbd3..e97438309a 100644 --- a/app/layout/project/sidebar/project/inventory-panel/features/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/features/index.tsx @@ -87,7 +87,9 @@ const InventoryPanelFeatures = ({ noData: noDataMessage }: { noData: string }): } ); - const featureIds = allFeaturesQuery.data?.map((feature) => feature.id); + const featureIds = allFeaturesQuery.data + ?.filter(({ isCustom }) => isCustom) + .map((feature) => feature.id); const handleSelectAll = useCallback( (evt: ChangeEvent) => { @@ -131,14 +133,6 @@ const InventoryPanelFeatures = ({ noData: noDataMessage }: { noData: string }): const feature = allFeaturesQuery.data?.find(({ id }) => featureId === id); const isContinuous = feature.amountRange.min !== null && feature.amountRange.max !== null; - // const isIncluded = newSelectedFeatures.includes(featureId); - // if (!isIncluded) { - // newSelectedFeatures.push(featureId); - // } else { - // const i = newSelectedFeatures.indexOf(featureId); - // newSelectedFeatures.splice(i, 1); - // } - if (isContinuous) { if (!isIncludedInContinuous) { continuousFeatures.push(featureId); @@ -184,6 +178,12 @@ const InventoryPanelFeatures = ({ noData: noDataMessage }: { noData: string }): isVisibleOnMap: layerSettings[feature.id]?.visibility ?? false, })); + useEffect(() => { + if (allFeaturesQuery.isRefetching) { + setSelectedFeaturesIds([]); + } + }, [allFeaturesQuery.isRefetching]); + return (
diff --git a/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx index 7eb51710b4..9893875af7 100644 --- a/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx @@ -36,7 +36,7 @@ const DeleteModal = ({ .getQueryData<{ data: Feature[]; meta: Pagination }>(['all-features', pid], { exact: false, }) - ?.data?.filter(({ id, isCustom }) => selectedFeaturesIds.includes(id) && isCustom) ?? [], + ?.data?.filter(({ id }) => selectedFeaturesIds.includes(id)) ?? [], [queryClient, selectedFeaturesIds, pid] );