projectstorm/react-diagrams

Adding NodeModel to NodeLayer set itself as its parent, but NodeModel's parent must be a Diagram

jeevcat opened this issue · 0 comments

The type the parent of a NodeModel must be a DiagramModel (which is a CanvasModel):

However, when adding a node to a layer, the layer sets the node's parent to itself:

As LayerModel doesn't inherit from DiagramModel, a class inheriting from NodeModel cannot correctly define its parent type to be a NodeLayerModel (due to the G extends NodeModelGenerics constraint), which is what the parent will actually be at runtime, if the node has been added to a layer.

The above also applies for links.