ibm-js/deliteful

Combobox: set value to "" as user is typing search string

wkeese opened this issue · 0 comments

Currently, a Combobox value of “123” could mean either that the user typed “123”, or that the user
typed “foo”, matching an item in the source like {id: “123”, label: “foo”}.

A related problem happens when the id is a substring of the label, ex {id: "12", label: "12 hours"}. Then backspacing from "12 hours" down to "12" triggers "12 hours" to be selected, and then the input is updated to say "12 hours" again.

Modify Combobox so that the value is only set by selecting something from the dropdown. When the user starts typing or backspacing, clear the value until something else is selected from the dropdown.

Application code that sets a value will then need to set displayedValue, even if the source items don’t have a separate label and id properties. Exception: if zero or multiple items are selected Combobox will use the right localized string automatically.

If we want an auto-complete widget where value is whatever is in the input (and the source items only contains labels, not ids), then that could be a subclass of Combobox.