Skip to content
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

Fixes dropdown breaking if a user types in invalid value and presses enter #5544

Merged
merged 6 commits into from Sep 14, 2023

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Sep 14, 2023

Fixes: #5540

Repro:

import gradio as gr

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            dropdown = gr.Dropdown(
                choices=["abc", "def", "ghi"],
                value="abc",
                allow_custom_value=False,
            )
            button = gr.Button()
        with gr.Column():
            out = gr.Textbox()

    button.click(fn=lambda x: x, inputs=dropdown, outputs=out)

if __name__ == "__main__":
    demo.queue().launch()

Notably, the Multiselect was not experiencing this bug.

Adds a couple of unit tests which don't actually test this exact bug (I couldn't figure out simulating the enter key -- tried keyboard("{Enter}") but it wasn't working for me), but they do test related behavior.

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Sep 14, 2023

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/bcb0df4630fdb5056212a774dac77f953c36617c/gradio-3.44.1-py3-none-any.whl

Install Gradio Python Client from this PR

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

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Sep 14, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/dropdown patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fixes dropdown breaking if a user types in invalid value and presses enter

Maintainers or the PR author can modify the PR title to modify this entry.

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
Collaborator

@hysts hysts left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! I tested it and it works fine for me.

@abidlabs abidlabs merged commit a0cc9ac into main Sep 14, 2023
20 of 21 checks passed
@abidlabs abidlabs deleted the dropdown-enter branch September 14, 2023 07:04
@pngwn pngwn mentioned this pull request Sep 14, 2023
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.

gr.Dropdown stops working when I type in a custom value and press enter if allow_custom_value=False
3 participants