From 75caf768f0b34eb3a225df63551cc22995a68923 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Wed, 24 Feb 2021 08:41:48 +0000 Subject: [PATCH] Fix click on empty space to deselect building --- app/src/frontend/hooks/use-building-data.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/frontend/hooks/use-building-data.ts b/app/src/frontend/hooks/use-building-data.ts index 8b2fc295..1263f076 100644 --- a/app/src/frontend/hooks/use-building-data.ts +++ b/app/src/frontend/hooks/use-building-data.ts @@ -30,10 +30,14 @@ export function useBuildingData(buildingId: number, preloadedData: Building): [B }, [buildingId]); const updateData = useCallback((building: Building) => { - if(building.verified == undefined) { - building.verified = {} as BuildingAttributeVerificationCounts; + if(building == undefined) { + setBuildingData(building); + } else { + if(building.verified == undefined) { + building.verified = {} as BuildingAttributeVerificationCounts; + } + setBuildingData(building); } - setBuildingData(building); }, []); useEffect(() => {