Nodes pasted inside loop have invalid opacity / z-index #21509

Closed
opened 2026-02-21 20:12:54 -05:00 by yindo · 1 comment
Owner

Originally created by @DavideDelbianco on GitHub (Jan 7, 2026).

Originally assigned to: @fatelei on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.2

Cloud or Self Hosted

Cloud

Steps to reproduce

Create a workflow
add a loop node
copy the nodes and paste them inside the loop node

✔️ Expected Behavior

the "add node" label should disappear when link the loop start to a child node
the nodes should not be transparent and use different stacking rules than natively added nodes

Actual Behavior

the "add node" option will not go away even after linking the start to a copied node.
the "add node" option will disappear after a reload
the pasted nodes will be children of loop node, but with a different z-index compared to nodes natively added to the loop
it seems like the nodes are not correctly detected as children

Image Image
Originally created by @DavideDelbianco on GitHub (Jan 7, 2026). Originally assigned to: @fatelei on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce Create a workflow add a loop node copy the nodes and paste them inside the loop node <!-- Failed to upload "Animazione.gif" --> ### ✔️ Expected Behavior the "add node" label should disappear when link the loop start to a child node the nodes should not be transparent and use different stacking rules than natively added nodes ### ❌ Actual Behavior the "add node" option will not go away even after linking the start to a copied node. the "add node" option will disappear after a reload the pasted nodes will be children of loop node, but with a different z-index compared to nodes natively added to the loop it seems like the nodes are not correctly detected as children <img width="851" height="324" alt="Image" src="https://github.com/user-attachments/assets/81174497-0af2-48ac-92c2-398fc5f66bed" /> <img width="963" height="595" alt="Image" src="https://github.com/user-attachments/assets/fdd0ff69-6cdf-41c2-8264-9eae82920c83" />
yindo added the 🐞 bug label 2026-02-21 20:12:54 -05:00
yindo closed this issue 2026-02-21 20:12:54 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 7, 2026):

This issue happens because when you paste nodes inside a loop, the code copies the z-index from the original node instead of always setting it to the special stacking value used for loop children (LOOP_CHILDREN_Z_INDEX). This means pasted nodes can appear behind or with different opacity compared to nodes added natively inside the loop. Also, the logic that updates the loop node’s _children array (which controls the visibility of the "add node" label) isn’t always triggered correctly for pasted nodes, so the label can stay visible until you reload, which forces a state refresh and corrects the UI.

To fix this, update the paste logic (in handleNodesPaste and handleNodeLoopChildrenCopy) so that any node pasted into a loop always gets zIndex: LOOP_CHILDREN_Z_INDEX and is properly added to the parent loop node’s _children array, just like when adding nodes natively. This will ensure stacking and child detection are consistent. You can see how native node addition does this in handleNodeAdd and related functions. For opacity, make sure no _dimmed flag is set on pasted nodes unless intentionally dimmed by the UI logic.

As a temporary workaround, reloading the page after pasting will force the UI to recalculate and display everything correctly, but a code fix is needed for a seamless experience.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 7, 2026): <!-- Answer --> This issue happens because when you paste nodes inside a loop, the code copies the z-index from the original node instead of always setting it to the special stacking value used for loop children (`LOOP_CHILDREN_Z_INDEX`). This means pasted nodes can appear behind or with different opacity compared to nodes added natively inside the loop. Also, the logic that updates the loop node’s `_children` array (which controls the visibility of the "add node" label) isn’t always triggered correctly for pasted nodes, so the label can stay visible until you reload, which forces a state refresh and corrects the UI. To fix this, update the paste logic (in `handleNodesPaste` and `handleNodeLoopChildrenCopy`) so that any node pasted into a loop always gets `zIndex: LOOP_CHILDREN_Z_INDEX` and is properly added to the parent loop node’s `_children` array, just like when adding nodes natively. This will ensure stacking and child detection are consistent. You can see how native node addition does this in `handleNodeAdd` and related functions. For opacity, make sure no `_dimmed` flag is set on pasted nodes unless intentionally dimmed by the UI logic. As a temporary workaround, reloading the page after pasting will force the UI to recalculate and display everything correctly, but a code fix is needed for a seamless experience. References: - [handleNodesPaste and z-index logic](https://github.com/langgenius/dify/blob/7ccf858ce61606ea4518a64ace44e4bbee4591b5/web/app/components/workflow/hooks/use-nodes-interactions.ts#L810-L2079) - [Loop node child copy and stacking](https://github.com/langgenius/dify/blob/7ccf858ce61606ea4518a64ace44e4bbee4591b5/web/app/components/workflow/nodes/loop/use-interactions.ts#L18-L151) - [AddBlock and label visibility](https://github.com/langgenius/dify/blob/7ccf858ce61606ea4518a64ace44e4bbee4591b5/web/app/components/workflow/nodes/loop/add-block.tsx#L20-L81) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6921ff1c-852f-4c7f-8a47-6ad5187710fa?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20issue%20happens%20because%20when%20you%20paste%20nodes%20inside%20a%20loop%2C%20the%20code%20copies%20the%20z-index%20from%20the%20original%20node%20instead%20of%20always%20setting%20it%20to%20the%20special%20stacking%20value%20used%20for%20loop%20children%20%28%60LOOP_CHILDREN_Z_INDEX%60%29.%20This%20means%20pasted%20nodes%20can%20appear%20behind%20or%20with%20different%20opacity%20compared%20to%20nodes%20added%20natively%20inside%20the%20loop.%20Also%2C%20the%20logic%20that%20updates%20the%20loop%20node%E2%80%99s%20%60_children%60%20array%20%28which%20controls%20the%20visibility%20of%20the%20%22add%20node%22%20label%29%20isn%E2%80%99t%20always%20triggered%20correctly%20for%20pasted%20nodes%2C%20so%20the%20label%20can%20stay%20visible%20until%20you%20reload%2C%20which%20forces%20a%20state%20refresh%20and%20corrects%20the%20UI.%0A%0ATo%20fix%20this%2C%20update%20the%20paste%20logic%20%28in%20%60handleNodesPaste%60%20and%20%60handleNodeLoopChildrenCopy%60%29%20so%20that%20any%20node%20pasted%20into%20a%20loop%20always%20gets%20%60zIndex%3A%20LOOP_CHILDREN_Z_INDEX%60%20and%20is%20properly%20added%20to%20the%20parent%20loop%20node%E2%80%99s%20%60_children%60%20array%2C%20just%20like%20when%20adding%20nodes%20natively.%20This%20will%20ensure%20stacking%20and%20child%20detection%20are%20consistent.%20You%20can%20see%20how%20native%20node%20addition%20does%20this%20in%20%60handleNodeAdd%60%20and%20related%20functions.%20For%20opacity%2C%20make%20sure%20no%20%60_dimmed%60%20flag%20is%20set%20on%20pasted%20nodes%20unless%20intentionally%20dimmed%20by%20the%20UI%20logic.%0A%0AAs%20a%20temporary%20workaround%2C%20reloading%20the%20page%20after%20pasting%20will%20force%20the%20UI%20to%20recalculate%20and%20display%20everything%20correctly%2C%20but%20a%20code%20fix%20is%20needed%20for%20a%20seamless%20experience.%0A%0AReferences%3A%20%20%0A-%20%5BhandleNodesPaste%20and%20z-index%20logic%5D%28https%3A//github.com/langgenius/dify/blob/7ccf858ce61606ea4518a64ace44e4bbee4591b5/web/app/components/workflow/hooks/use-nodes-interactions.ts%23L810-L2079%29%20%20%0A-%20%5BLoop%20node%20child%20copy%20and%20stacking%5D%28https%3A//github.com/langgenius/dify/blob/7ccf858ce61606ea4518a64ace44e4bbee4591b5/web/app/components/workflow/nodes/loop/use-interactions.ts%23L18-L151%29%20%20%0A-%20%5BAddBlock%20and%20label%20visibility%5D%28https%3A//github.com/langgenius/dify/blob/7ccf858ce61606ea4518a64ace44e4bbee4591b5/web/app/components/workflow/nodes/loop/add-block.tsx%23L20-L81%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30712)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21509