Skip to content

Conversation

@abidlabs
Copy link
Member

@abidlabs abidlabs commented Dec 9, 2025

This PR adds a .select() and .input() event to gr.FileExplorer. The .input() is like .change() but only fires with user interactions. The .select() event allows selecting individual files/directories in the FileExplorer.

I've also changed the UI a little bit for the FileExplorer. The value parameter is used to designate the selected files in the FileExplorer. I think it's rarely used when FileExplorer is non-interactive, but in the rare cases it might be used to output a subset of files, the current UI of showing the value as disabled checkboxes is not great. I've replaced with a background behind the respective files/folders:

image

If you add a .select() event, then you can then select individual files. Here's what the UI looks like:

Screen.Recording.2025-12-09.at.1.12.34.PM.mov

The updated demo/file_explorer_component_events/run.py file shows all this.

Closes: #12253
Closes: #12519

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 9, 2025

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/369c96f055051e3fbb180de2814ac15fcd7b0cca/gradio-6.1.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@369c96f055051e3fbb180de2814ac15fcd7b0cca#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/369c96f055051e3fbb180de2814ac15fcd7b0cca/gradio-client-2.0.0.tgz

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 9, 2025

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/fileexplorer minor
gradio minor

  • Add .select() and .input() events to gr.FileExplorer

✅ Changeset approved by @abidlabs

  • Maintainers can remove approval by unchecking this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatter script is catching these changes for me. I think they look reasonable anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of ruff are you on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah I was using a later version of ruff. Let me revert

@abidlabs abidlabs marked this pull request as ready for review December 9, 2025 21:42
Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR @abidlabs ! Left a comment on the select event for interactive file explorers. There is also a failing e2e test for the file explorer component. Looks good otherwise though!

tabindex={selectable ? 0 : undefined}
on:click|stopPropagation={() => {
if (selectable) {
handle_select([...index_path, i], [...path, name], type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file explorer is interactive, clicking on the textbox does not trigger the select event. Only clicking on the name triggers the select event. which is not intuitive

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd suggest triggering the select event if either the checkbox is clicked or the filename is clicked? I feel like they are different UI interactions so they should correspond to different events, but I don't feel too strongly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I originally thought the select event was not working because I was clicking the checkboxes and it was not triggering

@abidlabs
Copy link
Member Author

Thanks @freddyaboulton for the review, addressed and merging in now.

@abidlabs abidlabs enabled auto-merge (squash) December 10, 2025 20:44
@abidlabs abidlabs disabled auto-merge December 10, 2025 20:44
@abidlabs abidlabs merged commit f753b0c into main Dec 10, 2025
19 of 20 checks passed
@abidlabs abidlabs deleted the fe-select branch December 10, 2025 20:45
@freddyaboulton
Copy link
Collaborator

Thank you @abidlabs ! Will do a release by end of week to ship this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow downloading files from gr.FileExplorer Add input event to gr.FileExplorer

5 participants