You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please describe the feature that you want to propose
Whenever the user hits deleteKey, we don't delete the nodes/edges right away but let the user confirm the action in a confirmation dialog which gets invoked through onbeforedelete . Once the deletion is confirmed, we trigger deleteElements programmatically to delete these elements.
Unfortunately, deleteElements triggers onbeforedelete yet again, where we have to work around it with a hack to not open the confirmation dialog twice.
onbeforedelete currently gives back values like this: onbeforedelete={({ nodes, edges }) => {. If it would additionally give us back the event so we know if it was called by the user hitting the configured deleteKey or not, that would make our code much simpler.
Actually, probably all the custom event handlers of Svelteflow should give back event.
The text was updated successfully, but these errors were encountered:
@mcmxcdev You can just return true inside the onbeforedelete handler so the elements get deleted (false if deletion has not been confirmed). There is no need to actually programmatically delete the elements.
However, I still see you point. I assume there might be a reason to delete those elements programmatically, or to simply distinguish what has triggered the deletion (user input vs. program).
What do you think about an optional force parameter for deleteElements that skips onbeforedelete?
It's not that we trigger an async request in onbeforedelete that needs to be awaited until it can be deleted. It's a modal window that might or might not confirm the deletion. So we are taken completely out of the flow of onbeforedelete, hence we need programatical deletion.
However, I still see you point. I assume there might be a reason to delete those elements programmatically, or to simply distinguish what has triggered the deletion (user input vs. program).
Yes, 100%
What do you think about an optional force parameter for deleteElements that skips onbeforedelete?
That would sound reasonable to fix the issue I am experiencing, but other users might run into situations where they would need event exposed for other use cases, so I would still consider that important.
@mcmxcdev I don't think I understand what it means to be "completely out of the flow". You can pass an async function to onbeforedelete from an element outside of the flow. You can also create a promise and resolve it elsewhere.
If you can help me out by creating a sandbox which illustrates your issue, I believe I can show you how to do it.
Please describe the feature that you want to propose
Whenever the user hits
deleteKey
, we don't delete the nodes/edges right away but let the user confirm the action in a confirmation dialog which gets invoked throughonbeforedelete
. Once the deletion is confirmed, we triggerdeleteElements
programmatically to delete these elements.Unfortunately,
deleteElements
triggersonbeforedelete
yet again, where we have to work around it with a hack to not open the confirmation dialog twice.onbeforedelete
currently gives back values like this:onbeforedelete={({ nodes, edges }) => {
. If it would additionally give us back the event so we know if it was called by the user hitting the configureddeleteKey
or not, that would make our code much simpler.Actually, probably all the custom event handlers of Svelteflow should give back
event
.The text was updated successfully, but these errors were encountered: