Skip to content

Showing 0 instead of empty string in OptionsList #894

Open

Description

@inoyakaigor

In cases while Select had an Option with label '' (empty string) and value 0 the Select renders the 0
image

This hapens because of the code:

select/src/OptionList.tsx

Lines 339 to 341 in 824383d

// https://github.com/ant-design/ant-design/issues/34145
const content = typeof mergedLabel === 'number' ? mergedLabel : mergedLabel || value;
// https://github.com/ant-design/ant-design/issues/26717

For context: we had moved from our own ui-kit to Antd and in our ui-kit using the empty string was neccessary for resetting the select option

Activity

  1. clean99 commented on Dec 3, 2026

    @clean99
    Contributor

    In #894, an application migrating to Ant Design uses an empty option label for a reset entry, but the dropdown displays its value, 0.

    For options={[{ value: 0, label: '' }]}, the current default renderer falls back to the value. The selected single-value renderer preserves the empty label.

    This is longstanding behavior, not a new regression. #1254 explicitly preserved blank-string handling. The documented optionRender callback can bypass the default content fallback; this workaround has been checked in source, not run locally.

    If maintainers prefer a different default, the change would preserve literal-empty-string option labels without adding an API. It would leave the shared renderability helper and existing handling of null, undefined, false, numeric 0, whitespace labels, and custom renderers unchanged.

    Validation would use pure fallback-decision tests and browser checks for dropdown content, derived titles, selected labels, and keyboard selection, including blank and numeric-zero labels. No implementation has been prepared.

    Should an explicit empty-string option label remain blank by default, or should this use case continue to require optionRender?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions