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
Ensure input value saves on dropdown blur #5525
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/b9ca06a8aaff020f440be3026e510185fcc10911/gradio-3.44.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@b9ca06a8aaff020f440be3026e510185fcc10911#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
Thanks @hannahblair -- this change looks good. Could we also make the same change when If possible, would be great to add unit tests for this to to prevent any regressions. I'll try to increase the coverage of the unit tests for Dropdown/Multiselect in a separate PR. |
thanks for the review @abidlabs! ah yes, i've added that change to multiselect. also added a unit test 👍 |
Thanks for the quick fix @hannahblair! Taking a look |
I used this code to test: import gradio as gr
def printy(x):
print(x)
return x
with gr.Blocks() as demo:
gr.Markdown("Inputs")
d1 = gr.Dropdown(["choice 1", ("choice 2 [with value]", "value 2"), "choice 3"], label="single select", filterable=True,
multiselect=False)
d2 = gr.Dropdown(["choice 1", ("choice 2 [with value]", "value 2"), "choice 3"], label="multi select", filterable=True,
multiselect=True, max_choices=2)
d3 = gr.Dropdown(["choice 1", ("choice 2 [with value]", "value 2"), "choice 3"], label="single select allow_custom_value",
multiselect=False, allow_custom_value=True)
d4 = gr.Dropdown(["choice 1", ("choice 2 [with value]", "value 2"), "choice 3"], label="multi select allow_custom_value",
multiselect=True, max_choices=2, allow_custom_value=True)
gr.Markdown("Outputs")
t = gr.Textbox()
d1.change(printy, d1, t)
d2.change(printy, d2, t)
d3.change(printy, d3, t)
d4.change(printy, d4, t)
demo.launch() Noticed two issues:
|
…gradio into handle-dropdown-blur
My testing was lousy 😅 Fixed, thank you @abidlabs |
Beautiful @hannahblair! Just one nit above, otherwise looks good to merge. |
Merging so we can do the release. Thanks @hannahblair! |
Description
We weren't saving the current input value of the dropdown on blur - this PR fixes that 🐛
Closes: #5515
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh