diff --git a/packages/firecms_core/src/components/EntityCollectionView/useSelectionController.tsx b/packages/firecms_core/src/components/EntityCollectionView/useSelectionController.tsx index cb0d4c145..593d37e4e 100644 --- a/packages/firecms_core/src/components/EntityCollectionView/useSelectionController.tsx +++ b/packages/firecms_core/src/components/EntityCollectionView/useSelectionController.tsx @@ -10,9 +10,10 @@ export function useSelectionController = any>( const toggleEntitySelection = useCallback((entity: Entity, newSelectedState?: boolean) => { let newValue; if (newSelectedState === undefined) { - if (selectedEntities.map(e => e.id).includes(entity.id)) { + const isSelected = Boolean(selectedEntities.find(e => e.id === entity.id && e.path === entity.path)); + if (isSelected) { onSelectionChange?.(entity, false); - newValue = selectedEntities.filter((item: Entity) => item.id !== entity.id); + newValue = selectedEntities.filter((item: Entity) => !(item.id === entity.id && item.path === entity.path)); } else { onSelectionChange?.(entity, true); newValue = [...selectedEntities, entity]; @@ -23,14 +24,14 @@ export function useSelectionController = any>( newValue = [...selectedEntities, entity]; } else { onSelectionChange?.(entity, false); - newValue = selectedEntities.filter((item: Entity) => item.id !== entity.id); + newValue = selectedEntities.filter((item: Entity) => !(item.id === entity.id && item.path === entity.path)); } } setSelectedEntities(newValue); }, [selectedEntities]); const isEntitySelected = useCallback((entity: Entity) => { - return selectedEntities.map(e => e.id).includes(entity.id); + return Boolean(selectedEntities.find(e => e.id === entity.id && e.path === entity.path)); }, [selectedEntities]); return {