visgl / visgl/react-google-maps
[Bug] AdvancedMarker onDragEnd event triggers Map's onClick event
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 193
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 13
Description
Description
I have a Map instance with an onClick that sets the position of a marker to the latLng of the clicked position.
This marker is draggable, and onDragEnd shows an InfoWindow with the new position. The problem is that when onDragEnd ends the Map's onClick event fires. Both onClick and onDragEnd sets the position, but since they have a small difference this leads to the marker to jump to a close (but not exactly intended) position.
I expected the onClick event to not fire when AdvancedMarker onDragEnd fires.
Steps to Reproduce
Code SandBox:
SandBox
Steps:
- Open console
- Click on map to relocate marker
- Drag marker, pay attention to console.
- Drag map.
- Drag marker again, pay attention to console
Environment
- Library version: @vis.gl/react-google-maps@1.0.2
- Google maps version: weekly
- Browser and Version: 127.0
- OS: Windows 11
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using the linked CodeSandbox, starting with src/app.tsx and the AdvancedMarker and map event handlers shown there. Trace how dragging reaches onDragEnd and Map onClick, then verify that dragging the marker no longer triggers the map click callback while ordinary map clicks still do.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100