retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

addControl: Item has already been added to some node #419

Closed fogine closed 1 year ago

fogine commented 4 years ago

I believe there is a bug in code here, causing exception when calling node.addControl https://github.com/retejs/rete/blob/76605fda249796667a05d9a687b3c852f70b54a6/src/node.ts#L28-L29

as when not using typescript, Control instance has parent property qual to undefined.

Ni55aN commented 4 years ago

https://github.com/retejs/rete/blob/76605fda249796667a05d9a687b3c852f70b54a6/src/control.ts#L8

It's not a bug. Initially Control has parent = null. It seems that this control has already been added to some node, so you cannot add it again

CosasDePuma commented 3 years ago

There is no error. I got the same exception and my mistake was extending the class using

class CustomControl extends Rete.Component

instead of

class CustomControl extends Rete.Control

That's probably why you don't have the parent property defined.

rete-js[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.