Not possible to click on overlapping shapes

Open
#1,540 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

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.

Description

auto-triaged bug

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

Dominant language
JavaScript
Stars
1.1k
Forks
611
Avg merge
10h 34m
Merged PRs (30d)
5

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 mapbox/mapbox-gl-draw

All issues in mapbox/mapbox-gl-draw

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.