Skip to content

Commit 396b2e1

Browse files
Merge pull request #1107 from vinhyan/vinhyan/1025-Closing-tooltip-on-map-closes-property-details
Fix: Closing tooltip popup on map closes property details
2 parents 58a4d6e + 85346e2 commit 396b2e1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/PropertyMap.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ const PropertyMap: FC<PropertyMapProps> = ({
338338
useEffect(() => {
339339
if (!map) return;
340340
if (!selectedProperty) {
341-
// setPopupInfo(null);
341+
setPopupInfo(null);
342342
if (window.innerWidth < 640 && prevCoordinate) {
343343
map.setCenter(prevCoordinate as LngLatLike);
344344
setPrevCoordinate();
@@ -421,6 +421,12 @@ const PropertyMap: FC<PropertyMapProps> = ({
421421
e.target.getCanvas().style.cursor = cursorType;
422422
};
423423

424+
const handlePopupClose = () => {
425+
setSelectedProperty(null);
426+
setPopupInfo(null);
427+
history.replaceState(null, '', `/find-properties`);
428+
};
429+
424430
// map load
425431
return (
426432
<div className="customized-map relative max-sm:min-h-[calc(100svh-100px)] max-sm:max-h-[calc(100svh-100px) h-full overflow-auto w-full">
@@ -514,7 +520,7 @@ const PropertyMap: FC<PropertyMapProps> = ({
514520
longitude={popupInfo.longitude}
515521
latitude={popupInfo.latitude}
516522
closeOnClick={false}
517-
onClose={() => setPopupInfo(null)}
523+
onClose={handlePopupClose}
518524
>
519525
<div className="flex flex-row items-center nowrap space-x-1">
520526
<span>{toTitleCase(popupInfo.feature.address)}</span>

0 commit comments

Comments
 (0)