Skip to content

[combobox] ComboboxClear sets value to undefined which causes issues if controlled #3590

@psiho

Description

@psiho

Feature request

Summary

Currently, clicking ComboboxClear sets value to undefined which causes issues if it is controlled component, React complains. Trying simple onChange conversion to empty string works for the error, but now ComboboxClear icon never goes away (I guess it checks if value === undefined to hide).

Workaround is to conditionally render ComboboxClear. But I feel adding all this extra checks and conversions is not optimal. I'm not sure what would be the best way to resolve this. Simplest would be maybe to make ComboboxClear icon visibility to also check for empty string, not just undefined.

Or maybe for ComboboxClear to set value to empty string instead? Not sure how this would affect other things, but undefined and controlled fields don't play well together.

Motivation

I'm looking for minimal/clean way to make combobox work in controlled mode in React forms (RHF, or tanstack form)

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: comboboxChanges related to the combobox component.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions