Steps to reproduce
Expected
As the diagram doesn't have focus it shouldn't respond to the backspace key event. Nothing should happen.
Actual
The currently selected node is deleted.
This is an issue because I'm building a details edit panel, when I delete a character from the name it deletes the node. See this to get a better idea.
Poking into the code I can see that it's registering a page wide key hook and doesn't seem to:
Let me know if I've missed something, but if you let me know your preferred solution I'll submit a pull request (because this library is awesome).
Here's my naive/interim solution : https://github.com/Azim-Palmer/react-diagrams/commit/7ec6315d1ea7bc7d3b336cd404b33cb5ea9f3c1c
Fixed in storm-react-canvas (the new foundation for react-diagrams thats currently in development) (you have full control over the event bus)
Hi! Is there any fix for this project? should I move to react canvas instead? Im having the exact same problem, a popup or a focus on another element will still delete the node on backspace/delete.
thanks,
@rodobodolfo set deleteKeys as empty array
```jsx
..
deleteKeys={[]}
...
@sjy perfect, worked like a charm!! Thank you!!
@sjy @rodobodolfo , Can you please let me know where should I make this change ? I am facing the same issue.
Thanks
Gagan
@sjy @rodobodolfo , Can you please let me know where should I make this change ? I am facing the same issue.
Thanks
Gagan
pass it as a prop:
< SRD.DiagramWidget
deleteKeys={[]}
allowLooseLinks={false}
className="srd-diagram"
diagramEngine={this.engine}
/>
Also its bad pattern, but in entityRemoved listener you can throw an error
handleNodeRemoved = event => {
const userConfirmation = window.confirm('message');
if (!userConfirmation) {
throw new Error();
}
// delete instructions...
};
@Azim-Palmer @rodobodolfo @sjy @gj1118
Here's a more complete example that you can run and interact with. The end result is that I modified the delete functionality to only fire when shift is simultaneously pressed down. https://github.com/riyadshauk/oracle-digital-assistant-flow-js/blob/master/builder-web-app/src/base-components/ModifiedDiagramWidget.js
This example is built off of the Large Application example, but in the BodyWidget file, just use your own ModifiedDiagramWidget instead of { DiagramWidget } from 'storm-react-diagrams'.
node.registerListener({
entityRemoved :(e:any)=>{
e.stopPropagation();
}
});
then you can delete the node in your code
Most helpful comment
pass it as a prop: