jerosoler / Drawflow

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

Error when creating a connection #493

Closed TimKeitany closed 2 years ago

TimKeitany commented 2 years ago

I get this error when I make a connection between two nodes.

drawflow.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'connections') at i.dragEnd (drawflow.min.js:1:12791)

I am using the UI.

What might be the issue here?

Thanks

jerosoler commented 2 years ago

How are you adding the nodes?

It seems that it does not find the connection id in the stat.

TimKeitany commented 2 years ago

I am importing all the nodes first. Below is my json:

{"drawflow":{"Home":{"data":{"26":{"id":26,"name":"database","data":{},"class":"database","html":"

<div class=\"title-box\"><i class=\"fas fa-database\"><\/i> Database<\/div><\/div>","typenode":false,"inputs":{"input_9":{"connections":[]}},"outputs":{"output_21":{"connections":[]}},"pos_x":585,"pos_y":87},"29":{"id":29,"name":"questionnaire","data":{},"class":"questionnaire","html":"
<div class=\"title-box\"><i class=\"fas fa-clipboard-list\"><\/i> Questionnaire<\/div><\/div>","typenode":false,"inputs":{},"outputs":{"output_24":{"connections":[]}},"pos_x":84,"pos_y":148}}}}}

I suspect the issue emanates from this json but I cant seem to spot it.

jerosoler commented 2 years ago

The default inputs and outputs start in 1 in all nodes. Order is correlative.

"inputs": {
                        "input_1": {
                            "connections": []
                        },
                        "input_2": {
                            "connections": []
                        }
                    },
                    "outputs": {
                        "output_1": {
                            "connections": []
                        },
                        "output_2": {
                            "connections": []
                        }
                    },
TimKeitany commented 2 years ago

Hi @jerosoler . Thanks for the feedback. The issue is now resolved after I implemented your instructions.