carbon-components-react's ComboBox component only allows user to set initialSelectedItem but will be nice to have selectedItem like Dropdown component
Please describe your request in one or two sentences.
NA
NA
NA
NA
NA
Totally agree
@emyarod are you planning to implement it?
do you mind expanding on the Justification and Desired UX and success metrics?
Summary
carbon-components-react'sComboBoxcomponent only allows user to setinitialSelectedItembut will be nice to haveselectedItemlikeDropdowncomponent
Please describe your request in one or two sentences.Justification
It's not possible to add new values to ComboBox component. For example I have ComboBox with some values to choose from, but I want to have possibility to add new values to that ComboBox. So I create button for new value addition, and after submitting that new value I want it to appear in the ComboBox, but I don't want to set it as a InitialSelectedValue, because then it is not possible to remove it from that field.
Desired UX and success metrics
Design should not be changed, it just should have possibility to set Selected Value and that is all I need.
"Must have" functionality
ComboBox have SelectedItem prop.
@emyarod hope it will help you :)
@eglepuo is this the scenario you are describing? https://codesandbox.io/s/codesandbox-8misj
@emyarod yes
@eglepuo the example I wrote in that codesandbox is using the existing component. does that fit your use case?
also cc @harshzalavadiya
@emyarod looks nice
so the component already supports the functionality you're looking for in initialSelectedItem then right?
@emyarod thanks you! My problem was that I was trying to filter items from backend with OnInputChange function, and then this component was not working correctly, and changed to filtering function to frontend filtering with ShouldFilterItem and now it works as expected. I think we can close this issue. :)
@emyarod
Sorry I didn't looked at properly before but I guess you misunderstood issue
Currently Dropdown component has two props
initialSelectedItem: One time doesn't matter even if it changes won't affect dropdownselectedItem: Will update on state updateBut if you look at ComboBox
initialSelectedItem: Exists but rerenders component on changeselectedItem: Doesn't existIf Dropdown was suppose to be Same as Combobox but with search then should have same properties
https://codesandbox.io/s/codesandbox-3y85x
onChange event I'm setting value to formik store not to initial valuePossible workaround can be I can add react hook and set value everytime will work just fine but the I raised issue because of inconsistency of how props are behaving for both components
@harshzalavadiya
I won't be able to change the behavior of initialSelectedItem in <ComboBox /> to match <Dropdown /> until the next major version release as that would be a breaking change
but for now it sounds like adding selectedItem to <ComboBox /> would mirror the current initialSelectedItem behavior in <ComboBox /> is that right?
Yes sounds about right,
There's already workaround for this issue, so I totally understand breaking things might not be ideal.
Most helpful comment
Totally agree