Skip to content

fix(dropdown): preserve input value when choices update via key_up#13157

Open
viditkbhatnagar wants to merge 3 commits intogradio-app:mainfrom
viditkbhatnagar:fix/dropdown-keyup-value-clear-13127
Open

fix(dropdown): preserve input value when choices update via key_up#13157
viditkbhatnagar wants to merge 3 commits intogradio-app:mainfrom
viditkbhatnagar:fix/dropdown-keyup-value-clear-13127

Conversation

@viditkbhatnagar
Copy link
Copy Markdown

The value-sync effect in Dropdown.svelte reset input_text whenever choices changed, even during active typing. When key_up triggered a backend update with new choices, the effect saw value=null and cleared the input, also causing spurious change events.

Added is_focused guard so the value-sync effect skips resetting input_text while the user is typing. It still refreshes filtered_indices and selected_index for the new choices.

Added 3 tests covering search-as-you-type: preserving input text, no spurious change events, and showing updated options.

All 380 tests pass.

Fixes #13127

Description

Please include a concise summary, in clear English, of the changes in this pull request. If it closes an issue, please mention it here.

Closes: #(issue)

AI Disclosure

We encourage the use of AI tooling in creating PRs, but the any non-trivial use of AI needs be disclosed. E.g. if you used Claude to write a first draft, you should mention that. Trivial tab-completion doesn't need to be disclosed. You should self-review all PRs, especially if they were generated with AI.

  • I used AI to... [fill here]
  • I did not use AI

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

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

viditkbhatnagar and others added 2 commits March 27, 2026 23:52
The value-sync effect in Dropdown.svelte reset input_text whenever
choices changed, even during active typing. When key_up triggered
a backend update with new choices, the effect saw value=null and
cleared the input, also causing spurious change events.

Added is_focused guard so the value-sync effect skips resetting
input_text while the user is typing. It still refreshes
filtered_indices and selected_index for the new choices.

Added 3 tests covering search-as-you-type: preserving input text,
no spurious change events, and showing updated options.

All 380 tests pass.

Fixes gradio-app#13127
@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented Mar 30, 2026

🪼 branch checks and previews

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

Install Gradio from this PR

pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/cc033ce3910f5297c74bcc594acc8be554a1fe30/gradio-6.10.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/cc033ce3910f5297c74bcc594acc8be554a1fe30/gradio-client-2.1.0.tgz

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/dropdown patch
gradio patch

  • fix(dropdown): preserve input value when choices update via key_up

‼️ Changeset not approved. Ensure the version bump is appropriate for all packages before approving.

  • Maintainers can approve the changeset by checking 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.

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 value is cleared or choices fail to update when using key_up for dynamic filtering

3 participants