Skip to content

Commit

Permalink
Allows selection of directories in File Explorer (#9835)
Browse files Browse the repository at this point in the history
* changes

* changes

* changes

* add changeset

* changes

* Update js/fileexplorer/shared/FileTree.svelte

Co-authored-by: Hannah <hannahblair@users.noreply.github.com>

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 4, 2024
1 parent 6c8a064 commit 4d90883
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .changeset/bumpy-crews-open.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/fileexplorer": patch
"gradio": patch
---

fix:Allows selection of directories in File Explorer
44 changes: 26 additions & 18 deletions js/fileexplorer/shared/FileTree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,27 @@
{#each content as { type, name, valid }, i}
<li>
<span class="wrap">
<Checkbox
disabled={!interactive ||
(type === "folder" && file_count === "single")}
value={(type === "file" ? selected_files : selected_folders).some(
(x) => x[0] === name && x.length === 1
)}
on:change={(e) => {
let checked = e.detail;
dispatch("check", {
path: [...path, name],
checked,
type
});
if (type === "folder" && checked) {
open_folder(i);
}
}}
/>
{#if type === "folder" && file_count === "single"}
<span class="no-checkbox" aria-hidden="true"></span>
{:else}
<Checkbox
disabled={!interactive}
value={(type === "file" ? selected_files : selected_folders).some(
(x) => x[0] === name && x.length === 1
)}
on:change={(e) => {
let checked = e.detail;
dispatch("check", {
path: [...path, name],
checked,
type
});
if (type === "folder" && checked) {
open_folder(i);
}
}}
/>
{/if}

{#if type === "folder"}
<span
Expand Down Expand Up @@ -180,6 +183,11 @@
color: var(--color-accent);
}
.no-checkbox {
width: 18px;
height: 18px;
}
.hidden :global(> *) {
transform: rotate(0);
color: var(--body-text-color-subdued);
Expand Down

0 comments on commit 4d90883

Please sign in to comment.