jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.41k stars 713 forks source link

addConnection method do not edit connection data. #836

Closed darioillusorium closed 3 months ago

darioillusorium commented 3 months ago

Hi! I'm not sure if it is a known issue or i'm doing something wrong.

When I use de addConnection method, connection event "connectionCreated" occurs, I can catch the event and the connection data is correct but the drawflow node connection data is not updated. The connection is not added to the graph. However, if I connect it via interface (drag and drop output to input), all is correct: connectionCreated event occurs and node connection data is updated.

I use editor.value.addConnection(out_id, in_id, 'output_1', 'input_1') and seems to be correct, event occurs. But node connection data is not updated.

Thanks!

Darío :)

jerosoler commented 3 months ago

It seems that the function is correct. Maybe the values no out_id and in_id are not correct.

Try forcing node connections to refresh:

editor.updateConnectionNodes('node-5');

Remember that the use of the function is like this and the nodes must be created.

editor.addConnection(1, 2, 'output_1', 'input_1');
darioillusorium commented 3 months ago

Thanks for the quick response, it seems that everything is correct and I also tried to force it. But I don't get it. I'll keep researching to see if I find anything I might be doing wrong. If I find the reason I'll show you. Thank you so much.

darioillusorium commented 3 months ago

To give more context, if the ids do not exist the event does not occur. So due to in my case the event occurs, the IDs are correct. If the input_class or output_class does not exist, an exception is raised. Therefore I am also introducing correct classes.

I keep researching

darioillusorium commented 3 months ago

Sorry for the confusion, there was a procedure that was deleting my connections.

Thanks