visgl / visgl/react-map-gl

Marker jumps back to initial position during drag

Open
#2,481 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
8.5k
Forks
1.4k
Avg merge
5d 17h
Merged PRs (30d)
3

Description

If using onDragEnd to only update the internal app state when dragging is done instead of onDrag to constantly update it, the marker jumps back to the initial position whenever <Marker> rerenders even if none of the props changed.

I think this should not use marker.getLngLat() for comparison because this is update during draging but should save and use the last passed position from the caller.

https://github.com/visgl/react-map-gl/blob/057d67a41587afd11fb9c7f19d30c6c699f26ad6/modules/react-maplibre/src/components/marker.ts#L105-L107

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

Start in modules/react-maplibre/src/components/marker.ts at lines 105-107, then reproduce a drag using onDragEnd followed by a Marker rerender. Check how the caller's last position is compared with the marker position; done means the marker no longer jumps back when rerendered without prop changes.

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
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.