jerosoler / Drawflow

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

Issue with dynamically adding then removing output_1, output_2 #807

Closed mushzak closed 5 months ago

mushzak commented 6 months ago
image

I have flow like this, and adding outputs dynamically, when trying to remove last output it is working, but for example when I have output_1 output_2 output_3

when deleting output_2 having an issue offsetWidth, and suggestion how I can do this?

also need to remove from child node inputs

mushzak commented 6 months ago

for example when I remove node output_3 from condition_desc, it works, but when trying to remove 2nd it gives issue,

For adding new output I'm using this:

image
mushzak commented 6 months ago
image
jerosoler commented 6 months ago

In drawflow outputs and inputs as sequential number.

Example: If you have 3 outputs. And eliminate number 2. Outputs 1 and 2 will remain available.

You are using the functions: removeNodeOutput(id, output_class) and addNodeOutput(id)?

mushzak commented 6 months ago
image

I'm adding node output like this

jerosoler commented 6 months ago

Use

editor.addNodeOutput(idOfNode);
mushzak commented 6 months ago

if I use like this, how I can add lables?

image
mushzak commented 6 months ago

is there any function that I can check if output exists or not?

jerosoler commented 6 months ago

I don't know how you are adding the labels.

But once the connection is added you can always access the node information or add the label to the created connection.

You can get the node information with the function:

const dataNode = editor.getNodeFromId(idOfNode);

Here you can see the outputs and inputs of the nodes.

mushzak commented 6 months ago

is there any function that I can check if output exists or not?

jerosoler commented 6 months ago

There is no function. But you can use what was shown in the comment above to see if the output exists.

mushzak commented 6 months ago

tthis will remove "removeNodeOutput(id, output_class)" from child node inputs?

jerosoler commented 6 months ago

Yes

mushzak commented 6 months ago
image

having issues like this when using "removeNodeOutput(id, output_class)"

mushzak commented 6 months ago
image
mushzak commented 6 months ago
image

My problem is that I can have 3 outputs in the condition node, and then I can remove the second one, or the first one, and in this image, you can see what looks like. I don't have output_2 because I removed it. and after that, I'm having this issue.

image
jerosoler commented 6 months ago

In drawflow outputs and inputs are sequential number.

There can be no jump in them.

mushzak commented 5 months ago
image image
mushzak commented 5 months ago

image image

@jerosoler I'm using .removeNodeOutput() function wrongly?

mushzak commented 5 months ago

as I understand the problem is when node has any outputs + connection removeNodeOutput() gives error.

image
mushzak commented 5 months ago

When I try to remove first output which has a connection I see this error

image

when removing output_2 or output_3 it gives this error

image image

and it works when I remove connection and try remove output again

jerosoler commented 5 months ago

Please create a codepen to reproduce this problem.

mushzak commented 5 months ago

I'm not able to copy json from my working place, I can send screenshots

mushzak commented 5 months ago

I found the problem, closing the ticket, thanks.