mapbox / mapbox/mapbox-gl-draw

Not possible to click on overlapping shapes

Open
#1,540 0 comments 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

When multiple polygons overlap, clicking on a smaller polygon could select the larger polygon instead. The sortFeatures function was intended to sort polygons by area (smallest first), but area.geometry() is being called with a GeoJSON Feature wrapper instead of the raw geometry object. The area result ends us being always undefined and the sorting logic to fail.

Fix proposal
https://github.com/mapbox/mapbox-gl-draw/pull/1539

Steps to reproduce:

  • Draw a large polygon
  • Draw o smaller polygon in the middle of the larger polygon
  • Select the larger polygon
  • Deselect the larger polygon
  • Click on the smaller polygon

Expected result

  • Smaller polygon is selected

Actual result

  • Larger polygon is selected

Video

https://github.com/user-attachments/assets/24541dc7-70eb-409e-9cbd-59c3158351d1

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 with the sortFeatures function and inspect the area calculation described in the issue, especially how GeoJSON Feature wrappers and raw geometry objects are passed. Reproduce the overlapping-polygon steps, then verify that clicking the smaller polygon selects it; PR 1539 contains the proposed fix for comparison.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.