diff --git a/.changeset/light-rats-exist.md b/.changeset/light-rats-exist.md new file mode 100644 index 0000000000..61a0d4ff36 --- /dev/null +++ b/.changeset/light-rats-exist.md @@ -0,0 +1,6 @@ +--- +"@gradio/file": patch +"gradio": patch +--- + +fix:fix: prevent triggering gr.File.select on delete diff --git a/js/file/shared/FilePreview.svelte b/js/file/shared/FilePreview.svelte index c579fc463c..a44e41723d 100644 --- a/js/file/shared/FilePreview.svelte +++ b/js/file/shared/FilePreview.svelte @@ -31,6 +31,20 @@ }; }); + function handle_row_click( + event: MouseEvent & { currentTarget: HTMLTableRowElement }, + index: number + ): void { + const tr = event.currentTarget; + const should_select = + event.target === tr || // Only select if the click is on the row itself + event.composedPath().includes(tr.firstElementChild); // Or if the click is on the name column + + if (should_select) { + dispatch("select", { value: normalized_files[index], index }); + } + } + function remove_file(index: number): void { normalized_files.splice(index, 1); normalized_files = [...normalized_files]; @@ -45,15 +59,13 @@ >
{file.filename_stem} @@ -74,12 +86,15 @@ {i18n("file.uploading")} {/if} | + {#if normalized_files.length > 1}