Closed K0369 closed 8 months ago
Hey, thanks for yet another PR!
I would say that the behavior of the control should be the same as the keyboard shortcut (so delete group, not remove).
https://github.com/Blazor-Diagrams/Blazor.Diagrams/blob/master/src/Blazor.Diagrams.Core/Behaviors/KeyboardShortcutsDefaults.cs#L17
Now that I see this, I even forgot to check if the model is locked, could you also add that?
Sure.
Seeing that these deletion checks are used at least two times (in the KeyboardShortcutBehavior and now in the RemovalControl), it would maybe make sense to add this functionality to the diagram (e.g. as an extension). I'll see what I can come up with.
I have added a small fix for #359.
The RemoveControl is now checking if the "ShouldDelete" constraint is fulfilled before deleting node-models or links.
I have actually prepared the same change for groups too, but not added it to the PR because the behavior is actually different for groups, depending on the children (should they be removed, what if they have constraints, ...).
The current behavior for groups is to use the same path as node models (because they effectively are), which means that they aren't deleted because they are not in the NodeLayer. Also they don't use the "ShouldDeleteGroup" constraint, but the "ShouldDeleteNode" constraint.
Please let me know which group behavior you want to have implemented: