Is it possible to override the default 'Backspace' delete functionality?
I want to be able to rename the different nodes I'm using, but anytime a node is selected and I press backspace, it runs the onDelete function and wipes the node from the tree. Anyway to override this so backspace doesn't delete a node?
That's no fun.
There is no way to override it through a configuration (yet). It is coming in version 4.
For now, add an event listener for onKeyDown on your Node Renderer or Row Renderer, and call e.stopPropagation() if the key is the backspace key.
Perfect. Thanks!
I also am trying to delete a node with a button press instead/in addition to the default backspace press. I ended up hacking it like this:
const triggerBackspace = (node) => {
const event = new KeyboardEvent("keydown", {
key: "Backspace",
code: "Backspace",
keyCode: 8,
charCode: 8,
which: 8,
bubbles: true,
cancelable: true,
});
node.dispatchEvent(event);
}
node.focus()
triggerBackspace(document.activeElement)
Let me know if there is a better way to do this.