mirror of
https://github.com/langgenius/dify.git
synced 2026-03-26 22:52:38 +08:00
fix(workflow): clear loop/iteration metadata when pasting node outside container (#29983)
Co-authored-by: hjlarry <hjlarry@163.com>
This commit is contained in:
parent
eef13853b2
commit
c6c2715395
@ -1822,6 +1822,8 @@ export const useNodesInteractions = () => {
|
||||
else {
|
||||
// single node paste
|
||||
const selectedNode = nodes.find(node => node.selected)
|
||||
let pastedToNestedBlock = false
|
||||
|
||||
if (selectedNode) {
|
||||
const commonNestedDisallowPasteNodes = [
|
||||
// end node only can be placed outermost layer
|
||||
@ -1849,10 +1851,24 @@ export const useNodesInteractions = () => {
|
||||
}
|
||||
// set position base on parent node
|
||||
newNode.position = getNestedNodePosition(newNode, selectedNode)
|
||||
|
||||
// update parent children array like native add
|
||||
parentChildrenToAppend.push({ parentId: selectedNode.id, childId: newNode.id, childType: newNode.data.type })
|
||||
|
||||
pastedToNestedBlock = true
|
||||
}
|
||||
}
|
||||
|
||||
// Clear loop/iteration metadata when pasting outside nested blocks (fixes #29835)
|
||||
// This ensures nodes copied from inside Loop/Iteration are properly independent
|
||||
// when pasted outside
|
||||
if (!pastedToNestedBlock) {
|
||||
newNode.data.isInLoop = false
|
||||
newNode.data.loop_id = undefined
|
||||
newNode.data.isInIteration = false
|
||||
newNode.data.iteration_id = undefined
|
||||
newNode.parentId = undefined
|
||||
}
|
||||
}
|
||||
|
||||
idMapping[nodeToPaste.id] = newNode.id
|
||||
|
||||
Loading…
Reference in New Issue
Block a user