visgl / visgl/react-google-maps

[Bug] AdvancedMarker onDragEnd event triggers Map's onClick event

Open
#421 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. Open console
  2. Click on map to relocate marker
  3. Drag marker, pay attention to console.
  4. Drag map.
  5. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.