Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiselect: Not able to programatically change values #9151

Closed
2 tasks done
galilmori opened this issue Jul 9, 2021 · 4 comments
Closed
2 tasks done

Multiselect: Not able to programatically change values #9151

galilmori opened this issue Jul 9, 2021 · 4 comments

Comments

@galilmori
Copy link

galilmori commented Jul 9, 2021

What package(s) are you using?

  • carbon-components v10.36.0
  • carbon-components-react v7.36.0

Detailed description

  • MultiSelect.Filterable component doesnt have selectedItems property like its relative Dropdown component.
  • It only has the "initalSelectedItems" which allows to set the initial internal state.
  • This causes a big limitation and buggy behaviour where we cannot programmatically reset the internal values of the component.

What did you expect to happen?

  • allow programmatically setting internal selected values. same behaviour exists in Dropdown component

What happened instead?

  • with onChange i can retreive values selected but i cannot clear or set values without interraction with component after inital rendering

What would you like to see changed?

  • a way to programatically set values as it should be possible with all components

What browser are you working in?

  • Google Chrome

What offering/product do you work on?

  • Ibm cloud Power-iaas. This issue causes major blocker where we set values outside the component which are not reflected. also i cannot clear values in the component without the interraction with component check boxes or chip close button

Steps to reproduce the issue

  • create component with a list and provide the selected items in 'initialSelectedItems' or 'selectedItems' as it has been done in combobox and dropdown components
  • store initialSelected items in a react state
  • change that state by this.setState or with useState setter
  • the changes are not reflected

Reduced test case in CodeSandbox

@tay1orjones
Copy link
Member

Hey there! 👋

For initialSelectedItems, the hope with the prop name is that it reveals that what is passed to the component only represents what is selected on the initial render - it's not meant for after-creation updates. Renders after that will "desync" from what is provided in that initial value. Rendering the component with a new key should resolve this issue and force the component to recreate a new instance of the component.

@tay1orjones
Copy link
Member

Duplicate of #4812

@galilmori
Copy link
Author

galilmori commented Jul 23, 2021

Hi @tay1orjones

I hope that this is closed only because its a duplicate and not because of the "rendering with new key" workaround.
is this #4812 request going to be implemented? and when is the ETA? its open since 2019

@dhebert-dev
Copy link

I can confirm that since the issue was raised in 2019 nothing has been done to address the problem. This is causing a lot of difficulty for me and my team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants