ComfyUI_frontend icon indicating copy to clipboard operation
ComfyUI_frontend copied to clipboard

Copy and paste node isn't working.

Open comfyui-wiki opened this issue 3 months ago • 11 comments

Problem

Copy and paste functionality stops working after switching from legacy LiteGraph nodes to Vue nodes via keybinding. The issue demonstrates a broader interaction state management problem during mode transitions.

https://github.com/user-attachments/assets/d381cd78-7e31-4615-b78e-ff25fb91e579

Sequence:

  1. Legacy mode: Copy/paste works normally
  2. Switch to Vue nodes via Experimental.ToggleVueNodes keybinding
  3. Vue mode: Copy/paste completely broken

Root Cause

DOM Event Target Mismatch: The useCopy and usePaste composables fail to detect valid targets when Vue nodes are active.

Copy Detection Logic (useCopy.ts:23-30):

const isTargetInGraph =
  e.target.classList.contains('litegraph') ||
  e.target.classList.contains('graph-canvas-container') ||
  e.target.id === 'graph-canvas'

if (isTargetInGraph && canvas?.selectedItems) {
  canvas.copyToClipboard()  // Never executes in Vue mode
}

Problem: When Vue nodes are active, DOM focus shifts to Vue component elements that don't have the required classes/IDs, so isTargetInGraph returns false.

Technical Analysis

Mode Switching Works Correctly

  • Vue node toggle: useCoreCommands.ts:299-309
  • Selection sync: Vue nodes properly call canvas.select() and update canvas.selectedItems
  • State management: Mode transitions preserve graph state correctly

Event Handling Breaks

  • Legacy mode: LiteGraph canvas handles copy/paste directly
  • Vue mode: Relies on Vue composables with DOM target detection
  • Failure point: Target detection logic doesn't account for Vue component DOM structure

Selection System Comparison

Legacy Mode:

  • Selection handled by LGraphCanvas.select()/deselect()
  • Copy/paste handled by canvas event listeners
  • Target always matches #graph-canvas

Vue Mode:

  • Selection handled by useNodeEventHandlers composable
  • Copy/paste handled by separate Vue composables
  • Target becomes Vue component elements (no required classes)

Reproduction

  1. Load any workflow in legacy mode
  2. Select and copy a node (Ctrl+C) - works
  3. Press keybinding for Experimental.ToggleVueNodes command
  4. Try to select and copy nodes - fails silently
  5. Same issue affects paste (Ctrl+V)

Solution

Fix DOM target detection to work with Vue node elements:

Option 1: Expand Target Detection

const isTargetInGraph =
  e.target.closest('.litegraph') ||
  e.target.closest('.graph-canvas-container') ||
  e.target.closest('#graph-canvas') ||
  e.target.closest('[data-vue-node]')  // Vue node container

Option 2: Use Canvas Focus State

const canvas = canvasStore.canvas
const isCanvasFocused = document.activeElement?.closest('.graph-canvas-container')
if (isCanvasFocused && canvas?.selectedItems) {
  canvas.copyToClipboard()
}

Option 3: Unified Event Handling

Move copy/paste handling to a layer that works consistently across both modes.

Files Affected

Impact

This affects all keyboard shortcuts that use similar DOM target detection, not just copy/paste. Users lose core functionality when switching to Vue nodes.

Related

  • #5449 - General copy/paste issues in recent versions
  • #5697 - Vue node widget translation issues
  • Other Vue migration interaction problems

comfyui-wiki avatar Sep 20 '25 05:09 comfyui-wiki

In legacy mode, copying/pasting between workflows also stopped working

But we have workaround for pasting in another workflow: Press CTRL+V while pasting into a new workflow, then left-click on the canvas (empty space), then press CTRL+V again.

Shyryp avatar Sep 27 '25 22:09 Shyryp

@Shyryp Could you try disable custom nodes and try again?

For me, copy and paste only isn't working on Vue nodes, but it's still working on the current FE, and sometimes it might be blocked by browser extensions.

https://github.com/user-attachments/assets/41f665d7-a4dd-4022-ae68-d40554e292fd

comfyui-wiki avatar Sep 28 '25 01:09 comfyui-wiki

@Shyryp Could you try disable custom nodes and try again?

I used a completely clean ComfyUI, installed today from the portable version (from the release). I didn't use any custom nodes (I didn't install the manager either).

Shyryp avatar Sep 28 '25 01:09 Shyryp

For me, copy and paste only isn't working on Vue nodes, but it's still working on the current FE, and sometimes it might be blocked by browser extensions.

Screen.Recording.2025-09-28.at.09.09.10.mov

In your video, you demonstrate copying and pasting within the same workflow — yes, there are no problems with this, and there never were, in the standard (legacy) implementation.

However, I'm talking about copying and pasting BETWEEN workflows (between tabs with different workflows) in ComfyUI.

Try copying nodes in one workflow, and then trying pasting them in another workflow.

Shyryp avatar Sep 28 '25 01:09 Shyryp

https://github.com/user-attachments/assets/d686874a-456f-42d5-a35b-a8264a06ba18

@Shyryp

comfyui-wiki avatar Sep 28 '25 06:09 comfyui-wiki

Screen.Recording.2025-09-28.at.14.55.58.mov @Shyryp

Have you tried reproducing the issue using archives with the portable version of ComfyUI from the latest releases?

Try this after a clean installation, NOT after updating the older version of ComfyUI using update bat files.

Here's my video demonstrating the issue, including unpacking the portable version of ComfyUI and launching it. Pay attention to the keystrokes and mouse clicks.

Demo issue:

https://github.com/user-attachments/assets/85fe991d-dc64-4053-a745-412a80c45544

Installation process video (I'm simply unpacking and NOT modifying ANYTHING in ComfyUI):

https://github.com/user-attachments/assets/b82e3467-3dea-4284-93d8-38f9d951ca91

I downloaded the archive from here: https://github.com/comfyanonymous/ComfyUI/releases/tag/v0.3.60

I tested it on both Windows 10 and Windows 11. All browser plugins that could interfere with the pages are disabled or removed. CTRL+V works fine on other websites and local programs.

@comfyui-wiki

Shyryp avatar Sep 28 '25 13:09 Shyryp

After further investigating the issue, I discovered: If the workflow from which nodes are copied has been saved at least once to the file system, then copying from it to an unsaved new workflow using CTRL+V is impossible – only CTRL+SHIFT+V works. However, you still need to Left-Click the canvas at least once beforehand.

Demonstration (the key moment is at 0:35 – I save the workflow and then try to copy something from it to a new unsaved workflow):

https://github.com/user-attachments/assets/96ea7a26-e8c2-457b-8c54-193450a74626

After saving the workflow to the file system, no matter what I copy from it, nothing can be pasted into other workflows using the standard CTRL+V shortcut. Only CTRL+SHIFT+V works, and even then, only after clicking the canvas.

There are a number of other oddities and problems with copying and pasting that are difficult for me to explain (for example, sometimes copying via CTRL+V can suddenly work when copying from a saved workflow to an unsaved one, but this doesn't always work) - you can see everything in the video.

Shyryp avatar Sep 28 '25 13:09 Shyryp

https://github.com/user-attachments/assets/c2b6f1e1-0d9a-4cdd-a4e3-cc4b88e670f7

I still can't reproduce the same issue. I just downloaded the latest Portable and tested it. I'm not sure what happened on your end. Have you ever tried to reproduce the same issue on another computer?

comfyui-wiki avatar Sep 28 '25 14:09 comfyui-wiki

Screen.Recording.2025-09-28.at.22.05.16.mov I still can't reproduce the same issue. I just downloaded the latest Portable and tested it. I'm not sure what happened on your end. Have you ever tried to reproduce the same issue on another computer?

I tested it on four of my PCs.

Here's a video from my other PC, but on Windows 11 (Nvidia RTX 3060):

https://github.com/user-attachments/assets/aab1a97c-1db1-4422-923b-8fa3c99f96fc

In the video, on this other computer, I'm using the freshly unpacked latest release version of ComfyUI (link above). I didn't modify or update anything—I just launched it.

This problem isn't limited to my PCs; some of my friends are experiencing it too.

~~Could it be affected by having multiple keyboard layouts on the system? My friends and I each have two or three keyboard layouts. On my main PC I have keyboard layout "English (United State)", "English (Europe)", "Russian". On my PC from this video: "English (United State)", "Russian".~~ UPD: Having multiple keyboard layouts on a system doesn't affect this. A system with a single layout will still experience this issue.

In the videos, I only used the US English (United State) keyboard layout.

UPD2: Another user has the same problem - https://github.com/comfyanonymous/ComfyUI/issues/8481#issuecomment-3344151809

Shyryp avatar Sep 28 '25 16:09 Shyryp

@Shyryp Finally, I got what you mean now. However, since the issue you reported isn't related to the current one, I have submitted a feature request for you. If you want to track the progress of this feature support, you can leave any comment in this issue: https://github.com/Comfy-Org/ComfyUI_frontend/issues/5844

comfyui-wiki avatar Sep 29 '25 03:09 comfyui-wiki

I solved this problem by adding group and select nodes in the group then ctrl+c then ctrl+v to paste

vlatkan avatar Nov 29 '25 02:11 vlatkan

close it for now as it should fix in https://github.com/Comfy-Org/ComfyUI_frontend/pull/7103 and https://github.com/Comfy-Org/ComfyUI_frontend/pull/7166. Please feel free to reopen if it still exists after these changes

jtydhr88 avatar Dec 08 '25 17:12 jtydhr88