mapbox / mapbox/mapbox-gl-draw

Error when try to move vertex of a multi features in direct_select mode.

Open
#1,442 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

The cause of the error is that during the drag operation MultiFeature calls the takeAction function for every element in its feature array:

MultiFeature.prototype.updateCoordinate = function(path, lng, lat) {
takeAction(this.features, 'updateCoordinate', path, lng, lat);
this.changed();
};

These elements in the feature array are not directly included in the main Source. Therefore MultiFeature calls updateCoordinate of all internal features, and these will call the Store.featureChanged method with an featureId parameter that is not in Store of context of MapboxDraw.

Polygon.prototype.updateCoordinate = function(path, lng, lat) {
this.changed();
...
}

This causes that bad id entered into the _changedFeatureIds object, and then the

this.get(featureId).toGeoJSON()

throws error becuse get method returns undefined.

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 MultiFeature.prototype.updateCoordinate and trace its calls into Polygon.prototype.updateCoordinate and Store.featureChanged. Reproduce dragging a multi-feature in direct_select mode, then inspect _changedFeatureIds and the get(featureId).toGeoJSON() call. Done means the drag no longer records internal feature IDs that are absent from the Store or throws this error.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.