Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Dropdown labels for None-valued choices - #13842

Draft
dawoodkhan82 wants to merge 3 commits into
mainfrom
fix/dropdown-none-label
Draft

Fix Dropdown labels for None-valued choices#13842
dawoodkhan82 wants to merge 3 commits into
mainfrom
fix/dropdown-none-label

Conversation

@dawoodkhan82

@dawoodkhan82 dawoodkhan82 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes single-select Dropdowns whose choices include a display label mapped to None. The component now checks for a matching choice before treating a None value as an empty selection, so the label is shown while the submitted value remains None.

Closes: #13832

Before / after Spaces

Both Spaces run the same reproduction from the issue:

On load, compare the Choose an option field: the before Space leaves it blank, while the after Space shows Default. Then select Option A followed by Default; the after Space keeps Default visible and the result confirms that its submitted value is still None.

The temporary demo and wheel are hosted in the Spaces and are not committed to this branch.

AI Disclosure

  • I used AI to investigate the regression, draft and self-review the implementation and tests, create the comparison Spaces, and prepare this PR description.
  • I did not use AI

🎯 PRs Should Target Issues

This PR targets #13832. I checked for overlapping open PRs before starting and found none.

Testing and Formatting Your Code

  • Added focused Vitest component coverage for initial rendering and selecting a None-valued choice. No Playwright tests were added.
  • CI=1 pnpm exec vitest run --config .config/vitest.config.ts js/dropdown/dropdown.test.ts — 140 passed, 4 todo.
  • Targeted Prettier and ESLint checks passed for the changed frontend source; the test file is excluded by the repository ESLint configuration.
  • bash scripts/format_frontend.sh formatted the changes successfully. Its repository-wide type-check reports 16 existing errors in unrelated files.
  • No changeset was added manually; the repository's PR automation generated .changeset/late-dancers-invite.md from the PR title after the branch was pushed.

@gradio-pr-bot

gradio-pr-bot commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

🪼 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/ad46ca0b230b1522d311d252951f876c4284b361/gradio-6.26.0-py3-none-any.whl

Install Gradio Python Client from this PR

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

Import Gradio JS Client from this PR via CDN

import { Client } from "https://huggingface.co/buckets/gradio/npm-previews/resolve/ad46ca0b230b1522d311d252951f876c4284b361/browser.js";

@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 labels for None-valued choices

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The supported null choice behavior remains excluded by the frontend and Python public type contracts.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes single-select Dropdown labels for choices mapped to None.

Changes:

  • Resolves display labels before treating null as empty.
  • Adds initial-render and selection regression tests.
  • Adds generated patch changeset.
File summaries
File Description
js/dropdown/shared/Dropdown.svelte Handles matching null-valued choices.
js/dropdown/dropdown.test.ts Tests rendering and selecting null choices.
.changeset/late-dancers-invite.md Records patch releases.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +88 to +90
} else if (current_value === null) {
input_text = "";
selected_index = null;
@abidlabs

abidlabs commented Sep 10, 2026

Copy link
Copy Markdown
Member

I'm actually not sure if we should do this, as it might be a breaking change. Currently, we say that if if value is None, no value is initially selected. So could this break some apps where they expect None to always clear the Dropdown? Basically, there would be no way to programmatically clear the Dropdown anymore

Technically, the usage that was reported is not supported as values are supposed to be strings or numerics only. To get what they want, they just need to map "Default" to "Default" and then inside their function they could map to None?

@abidlabs

Copy link
Copy Markdown
Member

That being said, the current behavior is definitely not expected, so perhaps we just document this (we'll want to update the type hints for choices and values, and maybe in the frontend as well) and support this.

@dawoodkhan82
dawoodkhan82 marked this pull request as draft September 11, 2026 01:49
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.

gradio v6.26.0: Dropdown label not shown on field when option value is None

4 participants