Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trash is disabled while programatically selecting feature from draw using direct select #717

Open
jithintomz opened this issue Dec 5, 2017 · 5 comments
Labels
api API & programatically working with library bug ui Buttons & user interactions

Comments

@jithintomz
Copy link

jithintomz commented Dec 5, 2017

I am trying to select a newly created object in draw in code.

created_ids = draw.add(draw_feature); draw.changeMode('direct_select',{featureId:created_ids[0]});

The feature gets selected,but delete does not work on clicking trash icon.
When I deselect and reselect the feature using pointer delete works.

@mcwhittemore
Copy link
Contributor

@jithintomz please provide a fiddle of this bug happening along with the versions of mapbox-gl-draw and mapbox-gl-js that you are using per the issue template.

Regards,
Matthew

@n15e
Copy link

n15e commented Jan 17, 2019

This happens even on the example at
https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/

  1. Draw a polygon.
  2. Select it.
  3. Press delete.

It wont work.

However, if you deselect it, then re-select it, you can delete.

@ka7eh
Copy link

ka7eh commented Feb 13, 2019

Any update on this issue?

@kkaefer kkaefer added api API & programatically working with library bug ui Buttons & user interactions labels Jan 7, 2020
@suraj-bharti
Copy link

Here is the solution for deleting polygon.
created_ids = draw.add(draw_feature); draw.changeMode('simple_select',{featureIds:[created_ids[0]]});
It's working at my side, I hope it will work for you too.

@neodescis
Copy link
Contributor

FYI, it seems that not deleting a feature from direct select mode is intended behavior. However, you can override the mode's toTrash function and get it working. See this PR for how:

#975

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API & programatically working with library bug ui Buttons & user interactions
Projects
None yet
Development

No branches or pull requests

7 participants