fix: pass through dropdown value when not in choices for cascading dropdowns (fixes #12246)#13031
Closed
aayushbaluni wants to merge 1 commit intogradio-app:mainfrom
Closed
Conversation
…opdowns (fixes #12246) When a parent dropdown (e.g. country) changes and triggers an update to a child dropdown (e.g. city), the child receives the previous value as input. The child's choices may have been updated from a previous response, causing preprocess to raise 'Value not in list of choices'. Pass through the value to allow handlers to process stale values and return the updated component.
Collaborator
|
Hi @aayushbaluni The original issue was not reproducible in version 6. Please verify the issue exists before opening an ai-generated PR (and verify the ai's fix is actually applicable) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12246
When a parent dropdown (e.g. country) changes and triggers an update to a child dropdown (e.g. city), the child receives the previous value as input. The child's choices may have been updated from a previous response, causing preprocess to raise
Value not in list of choices.Root Cause
The Dropdown
preprocessmethod raised an error when the incoming value was not in the current choices. In cascading dropdowns (country/city), when the user changes country, the frontend sends the old city value. The backend's child dropdown may already have the new country's cities as choices from a previous update. Preprocess rejected the stale value before the handler could process it.Fix
Pass through the value to the handler when it is not in choices (single-value case). The handler can then return the updated component with the correct value.
Changes
Made with Cursor