Skip to content

Commit cc5e407

Browse files
committed
Prevent dragging from triggering click on marker
1 parent d53f9cc commit cc5e407

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/components/DraggableMarkers.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Dialog, DialogContent } from "@/components/ui/dialog";
1515
import { useState } from "react";
1616
import { Button } from "./ui/button";
1717

18+
let isDragging = false;
19+
1820
const ColoredMarker = ({
1921
latitude,
2022
longitude,
@@ -52,8 +54,20 @@ const ColoredMarker = ({
5254
}
5355
draggable={true}
5456
eventHandlers={{
55-
dragend: onChange,
56-
click: () => setOpen(true),
57+
dragstart: () => {
58+
isDragging = true;
59+
},
60+
dragend: (x) => {
61+
onChange(x);
62+
setTimeout(() => {
63+
isDragging = false;
64+
}, 100);
65+
},
66+
click: () => {
67+
if (!isDragging) {
68+
setOpen(true);
69+
}
70+
},
5771
}}
5872
/>
5973
<DialogContent className="!bg-[hsl(var(--sidebar-background))] !text-white">

0 commit comments

Comments
 (0)