mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

The delete coordinate keybinding is broken if displayControlsDefault: false

Open woodpav opened this issue 7 years ago • 3 comments

mapbox-gl-js: 0.47.0 mapbox-gl-draw: 1.0.9

var draw = new MapboxDraw({ 
    displayControlsDefault: false,
    keybindings: true,
});

draw.changeMode('draw_polygon');

Steps:

  1. Draw a polygon with your mouse
  2. Click one of the polygon's coordinates and select it
  3. Hit delete on your keyboard.

Expected:

The coordinate deletes and the polygon changes shape.

Actual:

The coordinate only deletes if displayControlsDefault: true.

Demo:

Try switching bugActive:

https://jsbin.com/gidotifaxa/1/edit?html,output

woodpav avatar Jul 24 '18 01:07 woodpav

I have a same problem.

zhaozhe0831 avatar Sep 19 '18 10:09 zhaozhe0831

Can't believe we still have this issue from 2018...

A temporary solution is to enable controls and then hide it in css...

.mapboxgl-control-container {
  display: none;
}

ShadowSonata avatar Jan 24 '23 04:01 ShadowSonata

Just for added observation, I think this is more to do with which control is enabled than just if keyBindings is false. For a delete vertex to work the trash control must be enabled (which means it is visible of course under regular circumstances). If the displayControlsDefault and keyBindings are both true the trash control value determines if a delete key will work.

This snapshot demos my observation. Just change the value of trashActive to show that without it enabled you cannot delete even though the displayControlsDefault and keyBindings are active: https://jsbin.com/kocijekexo/1/edit?html,output

As @ShadowSonata explains, the solution to not show a control but still get the behaviour is to provide some css to hide the specific control icon or the whole control container.

markphillips100 avatar Jan 25 '23 01:01 markphillips100