mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-05 21:20:12 +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:
@@ -1513,7 +1513,9 @@ export class ComfyApp {
|
||||
async handleFile(file: File, openSource?: WorkflowOpenSource) {
|
||||
const fileName = file.name.replace(/\.\w+$/, '') // Strip file extension
|
||||
const workflowData = await getWorkflowDataFromFile(file)
|
||||
if (_.isEmpty(workflowData)) {
|
||||
const { workflow, prompt, parameters, templates } = workflowData ?? {}
|
||||
|
||||
if (!(workflow || prompt || parameters || templates)) {
|
||||
if (file.type.startsWith('image')) {
|
||||
const transfer = new DataTransfer()
|
||||
transfer.items.add(file)
|
||||
@@ -1526,8 +1528,6 @@ export class ComfyApp {
|
||||
return
|
||||
}
|
||||
|
||||
const { workflow, prompt, parameters, templates } = workflowData
|
||||
|
||||
if (
|
||||
templates &&
|
||||
typeof templates === 'object' &&
|
||||
|
||||
Reference in New Issue
Block a user