Trigger click event from gr.DownloadButton even when no file is present (#7862)

* trigger click event download button

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Abubakar Abid 2024-03-27 13:16:01 -07:00 committed by GitHub
parent 425fd1ca9d
commit 0e125d7bef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/downloadbutton": patch
"gradio": patch
---
fix:Trigger click event from `gr.DownloadButton` even when no file is present

View File

@ -16,6 +16,7 @@
const dispatch = createEventDispatcher();
function download_file(): void {
dispatch("click");
if (!value?.url) {
return;
}
@ -33,7 +34,6 @@
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
dispatch("click");
}
</script>