mapbox / mapbox/mapbox-gl-draw

draw.create fired before map click event

Open
#1,173 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
8d 9h
Merged PRs (30d)
5

Description

**mapbox-gl-js 2.14.1**:
**mapbox-gl-draw 1.4.1**:

### Steps to Trigger Behavior
when double clicking to complete a polygon, the `draw.create` event is fired before the second `click` event is fired.
1. go to https://jsfiddle.net/dnltbrca/sdv4w16L/
2. open the browser console
3. draw a polygon and complete it by double clicking

### Expected Behavior
the console shows the order of the events: clicked, clicked, drawing created
### Actual Behavior
the order is clicked, drawing created, clicked

This is important because it can be architecturally undesirable to remove click handlers and then add them back after the drawing is finished. We used a flag to simply ignore these click events, but since the flag is disabled when the drawing is created the second click events does not get ignored.

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 event order using the linked JSFiddle with mapbox-gl-js 2.14.1 and mapbox-gl-draw 1.4.1, then trace the drawing-completion and click-event handling in the repository. Done means completing a polygon by double-click produces two click events before draw.create, with regression coverage if the existing test structure supports it.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.