Skip to content

Commit a615296

Browse files
authored
Merge pull request #33 from rezahedi/places-popup
Solve Two Issues Related to Places Markers and Popups
2 parents 64fa32a + debb670 commit a615296

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

src/pages/ExplorePage/PlanPopup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const PlanPopup = ({ plan }: { plan: Plan }) => {
77
<Link to={`/plans/${plan._id}`}>
88
<div className="flex gap-1 sm:w-xs sm:h-32">
99
<img
10-
className="w-24 h-full object-cover rounded-sm hidden sm:block"
10+
className="w-24 object-cover rounded-sm hidden sm:block"
1111
src={plan.images[0]}
1212
alt={plan.title}
1313
/>

src/pages/ExplorePage/places/PlacesMarkers.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ const PlacesMarkers = function Markers() {
1212

1313
const handleClick = useCallback(
1414
(placeId?: string, location?: [number, number]) => {
15+
if (selection && placeId === selection.placeId) return;
1516
if (placeId) setSelection({ placeId, location, source: "marker" });
1617
},
17-
[setSelection],
18+
[selection, setSelection],
1819
);
1920

2021
const handleMouseOver = useCallback(
2122
(placeId?: string, location?: [number, number]) => {
2223
if (placeId) {
24+
if (selection && placeId === selection.placeId) return;
2325
if (mouseOverTimeoutRef.current)
2426
clearTimeout(mouseOverTimeoutRef.current);
2527
mouseOverTimeoutRef.current = window.setTimeout(
@@ -28,7 +30,7 @@ const PlacesMarkers = function Markers() {
2830
);
2931
}
3032
},
31-
[setSelection],
33+
[selection, setSelection],
3234
);
3335

3436
const handleMouseOut = useCallback(

src/pages/ExplorePage/places/Popup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ const Popup = () => {
5555
if (!place) return null;
5656

5757
return (
58-
<div className="flex gap-1 sm:w-xs sm:h-32">
58+
<div className="flex gap-1 sm:w-xs">
5959
<img
60-
className="w-24 h-full object-cover rounded-sm hidden sm:block"
60+
className="w-24 object-cover rounded-sm hidden sm:block"
6161
src={place.imageURL}
6262
alt={place.name}
6363
/>

src/pages/PlanPage/Markers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ const Markers = ({ stops }: { stops: StopType[] }) => {
5353
position={selectedPlace.location}
5454
onClose={handlePopupClose}
5555
>
56-
<div className="flex gap-1 sm:w-xs sm:h-32">
56+
<div className="flex gap-1 sm:w-xs">
5757
<img
58-
className="w-24 h-full object-cover rounded-sm hidden sm:block"
58+
className="w-24 object-cover rounded-sm hidden sm:block"
5959
src={selectedPlace.imageURL}
6060
alt={selectedPlace.name}
6161
/>

src/pages/dashboard/create/Markers.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ const Markers = memo(function Markers() {
1010

1111
const handleClick = useCallback(
1212
(placeId?: string, location?: [number, number]) => {
13+
if (selection && placeId === selection.placeId) return;
1314
if (placeId) setSelection({ placeId, location, source: "marker" });
1415
},
15-
[setSelection],
16+
[selection, setSelection],
1617
);
1718

1819
const handlePopupClose = useCallback(() => {

src/pages/dashboard/create/PlacePopup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const PlacePopup = () => {
5656
if (!place) return null;
5757

5858
return (
59-
<div className="flex gap-1 sm:w-xs sm:h-32">
59+
<div className="flex gap-1 sm:w-xs">
6060
<img
61-
className="w-24 h-full object-cover rounded-sm hidden sm:block"
61+
className="w-24 object-cover rounded-sm hidden sm:block"
6262
src={place.imageURL}
6363
alt={place.name}
6464
/>

0 commit comments

Comments
 (0)