Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset FileInput value after load #958

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

AustinMroz
Copy link
Collaborator

When a file is browsed for, the fileInput remains associated with the chosen file even after the associated workflow is loaded. If a user attempts to load the same file again, the onchange event does not fire and loading fails silently. This is fixed by clearing the fileInput after the workflow has been loaded.

Out of an abundance of caution, the onchange is made async to ensure the fileInput isn't cleared until after the workflow has loaded.

This is a long standing issue which had befuddled me for many months.

@@ -382,8 +382,9 @@ export class ComfyUI {
accept: '.json,image/png,.latent,.safetensors,image/webp,audio/flac',
style: { display: 'none' },
parent: document.body,
onchange: () => {
app.handleFile(fileInput.files[0])
onchange: async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a playwright testcase for this change? See https://github.com/Comfy-Org/ComfyUI_frontend/tree/main/browser_tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use

async loadWorkflow(workflowName: string) {
await this.workflowUploadInput.setInputFiles(
this.assetPath(`${workflowName}.json`)
)
await this.nextFrame()
}
for file upload.

Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the setting changes in before/after tests for proper setup/teardown, as if the test expectation fails, the setting side-effect can cause other tests to fail.

@AustinMroz
Copy link
Collaborator Author

Is there a way to have the before and after functions to apply to just this test and not the Can load workflow with string node id test other than creating a new test group?

@huchenlei
Copy link
Member

Is there a way to have the before and after functions to apply to just this test and not the Can load workflow with string node id test other than creating a new test group?

I think the current way is to have a new describe group to hold the extra setup/teardown logic.

When a file is browsed for, the fileInput remains associated with the
chosen file even after the associated workflow is loaded. If a user
attempts to load the same file again, the onchange event does not fire
and loading fails silently. This is fixed by clearing the fileInput
after the workflow has been loaded.

Out of an abundance of caution, the onchange is made async to ensure the
fileInput isn't cleared until after the workflow has loaded.

Add a test to check if the same workflow file can be loaded
consecutively.
@huchenlei huchenlei merged commit c43bb20 into Comfy-Org:dev1.3 Sep 25, 2024
9 checks passed
huchenlei pushed a commit that referenced this pull request Sep 25, 2024
When a file is browsed for, the fileInput remains associated with the
chosen file even after the associated workflow is loaded. If a user
attempts to load the same file again, the onchange event does not fire
and loading fails silently. This is fixed by clearing the fileInput
after the workflow has been loaded.

Out of an abundance of caution, the onchange is made async to ensure the
fileInput isn't cleared until after the workflow has loaded.

Add a test to check if the same workflow file can be loaded
consecutively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants