New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable multi-select on gradio.Dropdown #2871
Conversation
Awesome, love the fact that the dropdown is typeable as well. Will be useful for very large number of choices. Some additional suggestions on the UI / UX side:
For example, the container with the
Try running: import gradio as gr
with gr.Blocks() as demo:
gr.Dropdown(["angola", "pakistan", "canada"], multiselect=True, value=["angola"])
demo.launch() vs. import gradio as gr
with gr.Blocks() as demo:
gr.Dropdown(["angola", "pakistan", "canada"], multiselect=False, value="angola")
demo.launch()
|
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dawoodkhan82 This is so cool! It's great that developers can update whether or not multi-select is enabled via gr.Dropdown.update
as well.
Left comments on some bugs I think I found.
In addition, I agree with @abidlabs comment about filtering with what's been typed and the look being too different from the existing dropdown.
gradio/components.py
Outdated
def update( | ||
value: Optional[Any] = _Keywords.NO_VALUE, | ||
choices: Optional[str | List[str]] = None, | ||
multiselect: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to make multiselect=None
otherwise any update to a multi-select dropdown will switch off the multiselect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not support update
changing backend configuration yet, such as multiselect
. update
only allows changing frontend configuration. So please remove multiselect
as an option to update
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
This reverts commit fb8762e.
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
great work. styling is still a bit off, I'll just make changes directly to branch. |
Just looking at this, I feel like should be a completely different element than Dropdown, e.g. a |
From a user's perspective, it feels "natural" to me to have a multiselect variant of the dropdown alongside a regular single-select dropdown. But I don't have a strong opinion, I'm fine with a separate component. If we do end up making it a different component, I think |
Synced with @aliabid94 , there's changes he suggested which makes sense and I'll implement:
|
This is going to be a really slick component! |
synced with @aliabid94 and @pngwn. Decided to move forward with the custom drop-down. Will look into combining the custom dropdown with datalist to improve accessibility, along with the other forms. |
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2871-all-demos |
1a08e23
to
a1d495f
Compare
gradio/components.py
Outdated
def update( | ||
value: Optional[Any] = _Keywords.NO_VALUE, | ||
choices: Optional[str | List[str]] = None, | ||
multiselect: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not support update
changing backend configuration yet, such as multiselect
. update
only allows changing frontend configuration. So please remove multiselect
as an option to update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks beautiful! Nit: can we add backend tests to ensure that preprocessing/postprocess multiselect works as we expect it to?
🎉 The demo notebooks match the run.py files! 🎉 |
Description
Add option to select multiple options on
gr.Dropdown
Will be updating the colors to match other form components.
Screen.Recording.2023-01-03.at.3.12.44.PM.mov
Please include:
Closes: #1076
Checklist:
A note about the CHANGELOG
Hello 👋 and thank you for contributing to Gradio!
All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.
Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by
[@myusername](link-to-your-github-profile)
in[PR 11111](https://github.com/gradio-app/gradio/pull/11111)
".If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.