mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-09 23:20:04 +00:00
fix: drag-and-drop screenshot creates LoadImage node instead of showing error (#8886)
## Summary Fix drag-and-drop of local screenshots onto the canvas failing to create a LoadImage node. ## Changes - **What**: Replace `_.isEmpty(workflowData)` check in `handleFile` with a check for workflow-relevant keys (`workflow`, `prompt`, `parameters`, `templates`). PNG screenshots often contain non-workflow `tEXt` metadata (e.g. `Software`, `Creation Time`) which made `_.isEmpty()` return `false`, skipping the LoadImage fallback and showing an error instead. ## Review Focus The root cause is that `getPngMetadata` extracts all `tEXt`/`iTXt` PNG chunks indiscriminately. Rather than filtering at the parser level (which could break extensions relying on arbitrary metadata), the fix checks for workflow-relevant keys before deciding whether to treat the file as a workflow or a plain image. Fixes #7752 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8886-fix-drag-and-drop-screenshot-creates-LoadImage-node-instead-of-showing-error-3086d73d3650817d86c5f1386aa041c2) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -196,5 +196,25 @@ describe('ComfyApp', () => {
|
||||
mockNode
|
||||
)
|
||||
})
|
||||
|
||||
it('should handle image files with non-workflow metadata by creating LoadImage node', async () => {
|
||||
vi.mocked(getWorkflowDataFromFile).mockResolvedValue({
|
||||
Software: 'gnome-screenshot'
|
||||
})
|
||||
|
||||
const mockNode = createMockNode()
|
||||
vi.mocked(createNode).mockResolvedValue(mockNode)
|
||||
|
||||
const imageFile = createTestFile('screenshot.png', 'image/png')
|
||||
|
||||
await app.handleFile(imageFile)
|
||||
|
||||
expect(createNode).toHaveBeenCalledWith(mockCanvas, 'LoadImage')
|
||||
expect(pasteImageNode).toHaveBeenCalledWith(
|
||||
mockCanvas,
|
||||
expect.any(DataTransferItemList),
|
||||
mockNode
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user