Ver Fonte

fix: duplicate block group item gets change

Ahmad Kholid há 2 anos atrás
pai
commit
3e3fb651df
1 ficheiros alterados com 8 adições e 3 exclusões
  1. 8 3
      src/newtab/pages/workflows/[id].vue

+ 8 - 3
src/newtab/pages/workflows/[id].vue

@@ -174,6 +174,7 @@ import {
   shallowRef,
   onBeforeUnmount,
 } from 'vue';
+import cloneDeep from 'lodash.clonedeep';
 import { getNodesInside } from '@braks/vue-flow';
 import { useI18n } from 'vue-i18n';
 import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router';
@@ -809,14 +810,17 @@ function copyElements(nodes, edges, initialPos) {
       }
     }
 
-    return {
+    const copyNode = cloneDeep({
       type,
       data,
       label,
       id: newNodeId,
       selected: true,
       position: nodePos,
-    };
+    });
+    copyNode.data = reactive(copyNode.data);
+
+    return copyNode;
   });
   const newEdges = edges.reduce(
     (acc, { target, targetHandle, source, sourceHandle }) => {
@@ -825,7 +829,7 @@ function copyElements(nodes, edges, initialPos) {
 
       if (!targetId || !sourceId) return acc;
 
-      acc.push({
+      const copyEdge = cloneDeep({
         selected: true,
         target: targetId,
         source: sourceId,
@@ -833,6 +837,7 @@ function copyElements(nodes, edges, initialPos) {
         targetHandle: targetHandle.replace(target, targetId),
         sourceHandle: sourceHandle.replace(source, sourceId),
       });
+      acc.push(copyEdge);
 
       return acc;
     },