fix: the new node name is generated based on the original node when duplicating (#4675)

This commit is contained in:
非法操作
2024-05-28 13:50:43 +08:00
committed by GitHub
parent eb8dc15ad6
commit b7f81f0999
2 changed files with 16 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ import {
Y_OFFSET,
} from '../constants'
import {
genNewNodeTitleFromOld,
generateNewNode,
getNodesConnectedSourceOrTargetHandleIdsMap,
getTopLeftNodePosition,
@@ -1067,7 +1068,6 @@ export const useNodesInteractions = () => {
const offsetY = currentPosition.y - y
clipboardElements.forEach((nodeToPaste, index) => {
const nodeType = nodeToPaste.data.type
const nodesWithSameType = nodes.filter(node => node.data.type === nodeType)
const newNode = generateNewNode({
data: {
@@ -1077,7 +1077,7 @@ export const useNodesInteractions = () => {
_isBundled: false,
_connectedSourceHandleIds: [],
_connectedTargetHandleIds: [],
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${nodeType}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${nodeType}`),
title: genNewNodeTitleFromOld(nodeToPaste.data.title),
},
position: {
x: nodeToPaste.position.x + offsetX,