Skip to content

[combobox] Input renders the raw value instead of the label provided in the root items #4735

@dd-jonas

Description

@dd-jonas

Bug report

Current behavior

When using a raw value in Combobox.Item, the Combobox.Input renders the value as input value, instead of the label provided in <Combobox.Root items={[...]} />.

For example, selecting the item "Apple" here would result in the string "1" as input value:

<Combobox.Root items={[{ value: 1, label: 'Apple' }]} />
  <Combobox.InputGroup>
    <Combobox.Input />
  </Combobox.InputGroup>

  <Combobox.Portal>
    <Combobox.Positioner>
      <Combobox.Popup>
        <Combobox.List>
          <Combobox.Item value={1}>Apple</Combobox.Item>
        </Combobox.List>
      </Combobox.Popup>
    </Combobox.Positioner>
  </Combobox.Portal>
</Combobox.Root>

Expected behavior

When passing a raw value to Combobox.Item, and an array of { label: string; value: unknown; } as root items, the Combobox.Input should lookup the correct label for the selected value and use that label as input value automatically. This would align the behavior with how Select.Trigger already works.
I'm assuming the difference is because Select.Trigger uses Select.Value by default, and the logic I'm describing is implemented only by Select.Value and Combobox.Value.

Notably, when providing a raw default value without label (e.g. defaultValue={1}), the input does render the correct label. This is the expected behavior that should also apply when selecting a value from the popup.

Reproducible example

Link to StackBlitz

Base UI version

v1.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: comboboxChanges related to the combobox component.type: expected behaviorThe current behavior is already the one expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions