Skip to content

Commit 4d90883

Browse files
aliabid94Ali Abidgradio-pr-bothannahblair
authored
Allows selection of directories in File Explorer (#9835)
* changes * changes * changes * add changeset * changes * Update js/fileexplorer/shared/FileTree.svelte Co-authored-by: Hannah <[email protected]> --------- Co-authored-by: Ali Abid <[email protected]> Co-authored-by: gradio-pr-bot <[email protected]> Co-authored-by: Hannah <[email protected]>
1 parent 6c8a064 commit 4d90883

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

.changeset/bumpy-crews-open.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/fileexplorer": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Allows selection of directories in File Explorer

js/fileexplorer/shared/FileTree.svelte

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,27 @@
6767
{#each content as { type, name, valid }, i}
6868
<li>
6969
<span class="wrap">
70-
<Checkbox
71-
disabled={!interactive ||
72-
(type === "folder" && file_count === "single")}
73-
value={(type === "file" ? selected_files : selected_folders).some(
74-
(x) => x[0] === name && x.length === 1
75-
)}
76-
on:change={(e) => {
77-
let checked = e.detail;
78-
dispatch("check", {
79-
path: [...path, name],
80-
checked,
81-
type
82-
});
83-
if (type === "folder" && checked) {
84-
open_folder(i);
85-
}
86-
}}
87-
/>
70+
{#if type === "folder" && file_count === "single"}
71+
<span class="no-checkbox" aria-hidden="true"></span>
72+
{:else}
73+
<Checkbox
74+
disabled={!interactive}
75+
value={(type === "file" ? selected_files : selected_folders).some(
76+
(x) => x[0] === name && x.length === 1
77+
)}
78+
on:change={(e) => {
79+
let checked = e.detail;
80+
dispatch("check", {
81+
path: [...path, name],
82+
checked,
83+
type
84+
});
85+
if (type === "folder" && checked) {
86+
open_folder(i);
87+
}
88+
}}
89+
/>
90+
{/if}
8891

8992
{#if type === "folder"}
9093
<span
@@ -180,6 +183,11 @@
180183
color: var(--color-accent);
181184
}
182185
186+
.no-checkbox {
187+
width: 18px;
188+
height: 18px;
189+
}
190+
183191
.hidden :global(> *) {
184192
transform: rotate(0);
185193
color: var(--body-text-color-subdued);

0 commit comments

Comments
 (0)