mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 23:34:31 +00:00
[backport core/1.33] Fix copy not working when text is selected in dialogs (#7269)
## Summary Backport of #7166 to core/1.33 branch. - Fixes copy not working when text is selected in dialogs - Also includes workflow priority fix (workflow checked before parameters) ## Conflicts Resolved - `src/scripts/app.ts`: Accepted incoming changes for workflow priority logic ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7269-backport-core-1-33-Fix-copy-not-working-when-text-is-selected-in-dialogs-2c46d73d365081b690bfc9dc1548618e) by [Unito](https://www.unito.io) Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -3,6 +3,14 @@ import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
* Utility functions for handling workbench events
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if there is selected text in the document.
|
||||
*/
|
||||
function hasTextSelection(): boolean {
|
||||
const selection = window.getSelection()
|
||||
return selection !== null && selection.toString().trim().length > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by clipboard handlers to determine if copy/paste events should be
|
||||
* intercepted for graph operations vs. allowing default browser behavior
|
||||
@@ -12,7 +20,7 @@ import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
* @returns true if copy paste events will be handled by target
|
||||
*/
|
||||
export function shouldIgnoreCopyPaste(target: EventTarget | null): boolean {
|
||||
return (
|
||||
const isTextInput =
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
(target instanceof HTMLInputElement &&
|
||||
![
|
||||
@@ -26,7 +34,6 @@ export function shouldIgnoreCopyPaste(target: EventTarget | null): boolean {
|
||||
'reset',
|
||||
'search',
|
||||
'submit'
|
||||
].includes(target.type)) ||
|
||||
useCanvasStore().linearMode
|
||||
)
|
||||
].includes(target.type))
|
||||
return isTextInput || useCanvasStore().linearMode || hasTextSelection()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user