Open schaveyt opened 2 years ago
Hi, there is a ShouldDeleteX
option for synchronously checking if it's allowed or not.
Would this functionality help you? https://github.com/Blazor-Diagrams/Blazor.Diagrams/issues/142
I believe you could also do it using a custom behavior, but that's not documented right now.
🤔 interesting. Let me research that and get back to u.
I am using Prompt for deleting the nodes but as I am deleting multiple nodes it is prompting that many times. How to avoid this?
With that code it doesn't handle multiple deletes?
I'm not sure how would that be handled in the library (multiple deletes at once)
It is handling but after cancel I want to reset the flags for next delete, so I handled in keydown event, but keydown event get called after this so no use.
Can we change ShouldDeleteNode for every node we create or it will be same for all nodes.?
It's the same for everything.
For now, can you try:
diagram.UnregisterBehavior<KeyboardShortcutsBehavior>();
// register your key press event
diagram.RegisterBehavior(new KeyboardShortcutsBehavior(diagram));
With that code it doesn't handle multiple deletes? I'm not sure how would that be handled in the library (multiple deletes at once)
If I want to create PR which branch to fork?
develop
branch. Although what solution are you thinking of?
I Am thinking to filter separate lists for all node,link and group and then check for ShouldDelete condition then do the delete so ShouldDelete will get call only once. whether it is multiple or single delete
Desired Behavior
Before the user deletes anything from the diagram, i must present a confirmation modal. If the user approved, one continues with deleting from the diagram as well as the application performing additional housekeeping. If the user cancels the deletion, the deletion should be aborted
Current Behavior
The user is able to press the
delete
key and diagram element is deleted. There is not way for me to intercept this and present the confirmation modal.For now, I set the DiagramOptions.DeleteKey = "" to prevent diagram deletions entirely.