modeling.removeElements doesn't delete all elements

modeling.removeElements appears to not work correctly. I try to delete a set of elements, but only a seemingly random (deterministic) subset is removed.

codesandbox here:

I have bound the spacebar key to remove selected elements. If you select multiple elements and press spacebar to remove them, you will get unexpected results.

I’m doing this because I don’t want to bind all keystrokes to the modeler. I have a wrapper environment that sends undo and redo commands to the modeler, so binding to the keyboard would duplicate the events. If there is a way to bind only a subset or invoke the events on the modeler, then that would be much better.

Thanks!

Thanks for sharing your codesandbox. One question: Why you are not using the EditorActions#removeSelection action?

const editorActions = bpmnJS.get("editorActions");

document.addEventListener("keyup", (e) => {
  if (e.which === 32) {
    editorActions.trigger("removeSelection");
  }
});

If there is a way to bind only a subset or invoke the events on the modeler, then that would be much better.

This is also possible, by overriding the existing keyboard bindings: https://codesandbox.io/s/bpmn-js-resize-tasks-2y2jd

I didn’t know this existed :sweat_smile:

The the solution for disabling keybindings is perfect! Thanks!