Skip to content

[Bug]: cds-combo-box with allow-custom-value overwrites its own value with the matched item's display text on open when a default value is setΒ #21860

@rsrduarteEG

Description

@rsrduarteEG

Package

@carbon/web-components

Browser

No response

Package version

v2.50.0

React version

No response

Description

When a cds-combo-box is configured with the allow-custom-value attribute and a default value is set (matching a cds-combo-box-item's value), opening the combo box causes the internal value of the cds-combo-box to be overwritten with the display text (label/innerText) of the matched item instead of preserving the original value.

Before:

Image

After:

Image

This breaks downstream selection logic that relies on value to match items, since it now holds the item's display label and no longer matches any item's value attribute β€” resulting in no item appearing as selected in the list.

Reproduction/example

https://stackblitz.com/edit/github-qzbdwvgx?file=index.html

Steps to reproduce

  1. Use the reproduction example code
  2. Inspect the value attribute/property of the cds-combo-box element (e.g., via DevTools).
  3. Click the combo box to open the list.
  4. Inspect again the value attribute/property of the cds-combo-box element after opened (e.g., via DevTools).

Expected Result:
The value property of cds-combo-box remains "item1" (the item's value attribute) after opening the component. The combo box list highlights the correct item as selected.

Actual Result:
Upon opening the combo box, the value property of cds-combo-box is changed to "Apple" (the item's display text/label). The combo box no longer recognizes any item as selected because no cds-combo-box-item has a value matching "Apple", breaking the selected state of the list.

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    ⏱ Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions