Resizing not working when a class inherit from go.Node

Hello,

I have a problem when resizing an element.

I’m using gojs-angular and gojs.

I’ve created a stackblitz to show you my problem.

There are two nodes template:

  • One is from a class testresize.model.ts, this class inherit from go.Node, and implement the template
  • One is a function in testresize.model.ts, this function do the exact same thing, except that the go.node is instanciated. (I don’t want to keep this function, this is just to show you the problem)

I don’t understand why the solution 1 isn’t working.

Do you have any ideas?

Thank you

It is unusual to subclass Node (or Group) but it can work.

I am unable to run your StackBlitz example, but will try again later.

For unknown reasons your code doesn’t run at all. But at least I can see your code.

The problem with your TestResize class is that the constructor is allocating and adding some elements – a Panel and a Shape and a TextBlock. But that will cause a problem as soon as a TestResize is copied – the TestResize constructor is called and then it walks the visual tree, copying each of the elements, resulting in duplicate elements. There might be other problems too. So don’t do that.

I’m wondering why you wanted to subclass Node. The only good reason that I know of is to override one or two methods for which there is no alternative. And maybe we ought to extend the API so even those reasons are no longer necessary.

Thanks you for your responses.

I will change my class to avoid subclassing node.

Have a nice day