Skip to content

Commit 5233749

Browse files
Fix copy not working when text is selected in dialogs (#7166)
## Summary - Allow default browser copy (Ctrl+C / Cmd+C) when text is selected anywhere in the document - Previously, the graph node copy handler intercepted copy events even in dialogs ## Problem Users could not copy error messages from the PromptExecutionError dialog or other modal dialogs. When pressing Ctrl+C with text selected in a dialog, the graph copy handler would intercept the event and prevent the default browser copy behavior. ## Solution Add a `hasTextSelection()` check to `shouldIgnoreCopyPaste()`. When the user has any text selected in the document, the function returns `true`, allowing the default browser copy to proceed. ## Test plan - [ ] Open an error dialog (trigger a workflow error) - [ ] Click "Show Report" to expand error details - [ ] Select some text in the dialog - [ ] Press Ctrl+C (or Cmd+C on Mac) - [ ] Paste elsewhere to verify the text was copied - [ ] Verify graph node copy still works when no text is selected https://github.com/user-attachments/assets/30a0c501-95ee-4148-b321-3d60339a41c5 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7166-Fix-copy-not-working-when-text-is-selected-in-dialogs-2bf6d73d36508182a240fd3153cb6969) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <[email protected]>
1 parent 45bcf40 commit 5233749

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/scripts/app.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,9 @@ export class ComfyApp {
14571457
})
14581458
return
14591459
} else {
1460-
console.error('Invalid workflow structure, trying parameters fallback')
1460+
console.error(
1461+
'Invalid workflow structure, trying parameters fallback'
1462+
)
14611463
this.showErrorOnFileLoad(file)
14621464
}
14631465
} catch (err) {

src/workbench/eventHelpers.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
33
* Utility functions for handling workbench events
44
*/
55

6+
/**
7+
* Check if there is selected text in the document.
8+
*/
9+
function hasTextSelection(): boolean {
10+
const selection = window.getSelection()
11+
return selection !== null && selection.toString().trim().length > 0
12+
}
13+
614
/**
715
* Used by clipboard handlers to determine if copy/paste events should be
816
* intercepted for graph operations vs. allowing default browser behavior
@@ -12,7 +20,7 @@ import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
1220
* @returns true if copy paste events will be handled by target
1321
*/
1422
export function shouldIgnoreCopyPaste(target: EventTarget | null): boolean {
15-
return (
23+
const isTextInput =
1624
target instanceof HTMLTextAreaElement ||
1725
(target instanceof HTMLInputElement &&
1826
![
@@ -26,7 +34,6 @@ export function shouldIgnoreCopyPaste(target: EventTarget | null): boolean {
2634
'reset',
2735
'search',
2836
'submit'
29-
].includes(target.type)) ||
30-
useCanvasStore().linearMode
31-
)
37+
].includes(target.type))
38+
return isTextInput || useCanvasStore().linearMode || hasTextSelection()
3239
}

0 commit comments

Comments
 (0)