mapbox / mapbox/mapbox-gl-draw
`draw.changeMode('simple_select'); map.removeControl(draw);` does not reset mouse cursor
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
We have a map that sometimes is in draw mode and sometimes isn't. When we exit draw mode, we want to remove the map controls and reset the mouse cursor from the crosshairs to the hand icon.
`draw.changeMode('simple_select')` resets the cursor to the hand if we call it in isolation, but if we immediately call `map.removeControl(draw)` after the `changeMode` then the cursor is never reset. Also, calling `map.removeControl(draw)` in isolation does not remove the cursor.
Here is a jsbin showing the issue: https://jsbin.com/powodeyiri/edit?html,output
Interestingly, we have been able to work around the problem by doing this instead:
```
draw.changeMode('invalid mode');
map.removeControl(draw);
```
I'm unclear on whether this is a bug or if there's a better way to deactivate the draw controls and reset the cursor at the same time.
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
Start with the linked JSBin and reproduce the cursor behavior using draw.changeMode('simple_select') followed by map.removeControl(draw). Trace those two entry points to determine why the hand cursor is not restored; done means exiting draw mode and removing the control consistently reset the cursor without relying on an invalid mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100