Browse Source

fixing delete on node delete

Pamela Wolf 4 năm trước cách đây
mục cha
commit
3ddee29b08
2 tập tin đã thay đổi với 18 bổ sung12 xóa
  1. 0 12
      nodeEditor/src/diagram/graphFrame.ts
  2. 18 0
      nodeEditor/src/graphEditor.tsx

+ 0 - 12
nodeEditor/src/diagram/graphFrame.ts

@@ -1377,18 +1377,6 @@ export class GraphFrame {
     }
 
     public dispose() {
-        if(this.isCollapsed) {
-            while(this._nodes.length > 0) {
-                this._nodes[0].dispose();
-            }
-            this.isCollapsed = false;
-        }
-        else {
-            this._nodes.forEach(node => {
-                node.enclosingFrameId = -1;
-            });
-        }
-
         if (this._onSelectionChangedObserver) {
             this._ownerCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
         };

+ 18 - 0
nodeEditor/src/graphEditor.tsx

@@ -202,6 +202,24 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
                 }
 
                 if (this._graphCanvas.selectedFrame) {
+                    if(this._graphCanvas.selectedFrame.isCollapsed) {
+                        while(this._graphCanvas.selectedFrame.nodes.length > 0) {
+                            let targetBlock = this._graphCanvas.selectedFrame.nodes[0].block;
+                            this.props.globalState.nodeMaterial!.removeBlock(targetBlock);
+                            let blockIndex = this._blocks.indexOf(targetBlock);
+        
+                            if (blockIndex > -1) {
+                                this._blocks.splice(blockIndex, 1);
+                            }
+                            this._graphCanvas.selectedFrame.nodes[0].dispose();            
+                        }
+                        this._graphCanvas.selectedFrame.isCollapsed = false;
+                    }
+                    else {
+                        this._graphCanvas.selectedFrame.nodes.forEach(node => {
+                            node.enclosingFrameId = -1;
+                        });
+                    }
                     this._graphCanvas.selectedFrame.dispose();
                 }