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.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

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.

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

Dominant language
TypeScript
Stars
8.5k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from visgl/react-map-gl

All issues in visgl/react-map-gl

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.