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

Retain dropdown value if choices have been changed #7401

Merged
merged 3 commits into from Feb 12, 2024
Merged

Conversation

abidlabs
Copy link
Member

@abidlabs abidlabs commented Feb 12, 2024

Closes: #6853 and adds a unit test.

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Feb 12, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detecting...

Install Gradio from this PR

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

Install Gradio Python Client from this PR

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

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Feb 12, 2024

🦄 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.

Retain dropdown value if choices have been changed

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.

@abidlabs abidlabs changed the title dropdown choice bug Retain dropdown value if choices have been changed Feb 12, 2024
@abidlabs abidlabs marked this pull request as ready for review February 12, 2024 19:44
old_choices = choices;
filtered_indices = handle_filter(choices, input_text);
if (!allow_custom_value && filtered_indices.length > 0) {
Copy link
Member Author

Choose a reason for hiding this comment

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

A little bit of code duplication from below, but I think its easier to follow this way

@hannahblair
Copy link
Collaborator

Nice! Tested that the fix works 🚀 Can you explain what caused the issue here?

@abidlabs
Copy link
Member Author

Thanks @hannahblair for the review! The issue was that we weren't calling set_input_text(); if choices was updated.

@abidlabs abidlabs merged commit dff4109 into main Feb 12, 2024
8 checks passed
@abidlabs abidlabs deleted the dropdown-bugs branch February 12, 2024 23:52
@pngwn pngwn mentioned this pull request Feb 12, 2024
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.

Dropdown doesn't retain value if choice name is changed
3 participants