Reset FileInput value after load (#958)

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.
This commit is contained in:
AustinMroz
2024-09-25 01:25:32 -05:00
committed by Chenlei Hu
parent 5ee0fd3519
commit 9199639320
2 changed files with 23 additions and 2 deletions

View File

@@ -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 () => {
await app.handleFile(fileInput.files[0])
fileInput.value = ''
}
})