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 - ability to have more control over and clear selected items #4812

Closed
kabeaty opened this issue Dec 3, 2019 · 13 comments · Fixed by #10236 · May be fixed by dezkareid/carbon#1
Closed

MultiSelect - ability to have more control over and clear selected items #4812

kabeaty opened this issue Dec 3, 2019 · 13 comments · Fixed by #10236 · May be fixed by dezkareid/carbon#1
Assignees
Labels
component: multiselect hacktoberfest See https://hacktoberfest.com/ package: react carbon-components-react proposal: accepted This request has gone through triaging and we are accepting PR's against it. role: dev 🤖 type: enhancement 💡

Comments

@kabeaty
Copy link

kabeaty commented Dec 3, 2019

Summary

I would like to request that the MultiSelect component be updated so that it's possible to have more control over the selection of items and clearing of already selected items, including clearing all selected items at once. Something similar was previously discussed in this issue that I found with a solution that I ended up using for now for my use case (#2623). Also in that issue, the implementation for this requested enhancement that was floated as possibly being the way to go was surfacing Downshift's action props to help with clearing selection/items/etc.

Justification

This came up in our project when we needed to be able to clear all selections in the MultiSelect component for our Watson Discovery React components from one button that also clears all selections across other components, which use Carbon's Checkbox. You can see the related pull request here, which has more detail, if it helps: watson-developer-cloud/discovery-components#11

Desired UX and success metrics

The desired UX is that a developer who uses the MultiSelect React component is able to control the component's selections, both selecting and deselecting, from a button or other component instead of one at a time by the user. We can measure the success for the developer if it's possible to do this with props, and there is no longer any need to reference the DOM, as in the solution included in the previous issue above ^.

"Must have" functionality

Ability to clear all selected items at once is the "must have" functionality for this request.

Specific timeline issues / requests

No, but I wanted to surface this since it's a question that was asked in the past for a similar use case to get it back on the team's radar.

Available extra resources

I am a front-end developer who would be able/willing to help with implementing these changes. I wanted to first open this feature request and get feedback from the Carbon team though before proceeding. Please let me know any additional details/info I can provide, thank you!

@abbeyhrt
Copy link
Contributor

abbeyhrt commented Mar 6, 2020

Hi @kabeaty! 👋 Thanks for making this enhancement request! On our side, we would love to support this work if you would like to contribute it! We do give users the ability to forward downShift props to the MultiSelect and we have a PR in the works to upgrade our Downshift dependency to its latest version which might provide more functionality for what you're trying to do!

@abbeyhrt abbeyhrt removed their assignment Mar 12, 2020
@joshblack joshblack added proposal: accepted This request has gone through triaging and we are accepting PR's against it. and removed proposal: open This request has gone through triaging. We're determining whether we take this on or not. labels Apr 10, 2020
@tw15egan tw15egan added hacktoberfest See https://hacktoberfest.com/ and removed hacktoberfest See https://hacktoberfest.com/ labels Sep 29, 2020
@tw15egan
Copy link
Member

Here's an example on sandbox:
https://codesandbox.io/s/modest-merkle-fzltr

@caritaou
Copy link

We are seeing the same problem, scenario is documented here: elyra-ai/canvas#510

We are using a checkbox to modify the values of the items that are passed to the Multiselect. In doing so, if there were any previous initialSelectedItems, we are trying to clear that. But as mentioned in this issue, we are not able to do so.

I was able to make slight progress by modifying the state directly, but that doesn't work anymore as soon as the user select another option. We are not able to reset the selected options after a user makes a selection.

image
From the above image, we can see that there are no selected options passed into the Multiselect control, but there are still items shown as selected:
image

@sali2801
Copy link

sali2801 commented Aug 4, 2021

any update on this please? I am still not able to reset the multiselect programmatically

@galilmori
Copy link

What is the ETA for this? we need this to programmatically control this. The "key" workaround has limits.

@dhebert-dev
Copy link

I am also running into an issue with programmatically selecting an existing item when the user attempts to import information into a form which contains this component.

@gipscoh
Copy link

gipscoh commented Oct 19, 2021

Hi
I have the same problem.

I can't control value in multi-select (select All value, set current values, reset value).

THIS PROBLEM SINCE THE 2019 YEAR. AND the Carbon team didn't do anything.

I don't want to wait and I made a component based on React-multi-select-component with styles carbon.

(temporary solution)
Now I use my custom component:
https://codesandbox.io/s/react-multi-select-component-example-forked-o594c?file=/src/index.js

PS CARBON TEAM - Please stop the closed topics without solving the problem.

@joshblack
Copy link
Contributor

joshblack commented Oct 20, 2021

Hey there @gipscoh, please try and keep the conversation productive and respectful. I definitely understand being frustrated when components that we offer don't support an important use case for your work. I am so sorry when people run into that with the project, it's never our intention and we try our best to prioritize and fix as much as we can. Unfortunately, that means that some things won't be addressed if other items are prioritized 😞

I'm not sure what your intent was with your message but what you shared in all caps or the bolded text can come across in a way that's hurtful or unproductive to contributors on this project. I hope the background and context that I provided are helpful and ask that you keep that in mind in the future.

On our end, we're always trying to take on more issues and address problems that people have with the project. We're also always open for teams to submit their own Pull Requests to add missing functionality or address fixes, as well. I hope you understand.

I also wanted to say thanks to everyone on this thread for sharing details about this problem and apologize for how long this has been an issue. Just to reiterate, we're always happy to work with teams and accept contributions for things like this if people have the time. On our end, we'll also try to prioritize as appropriate. Something that can help out a ton on our end is to "thumbs up" the issue using a reaction. We have a good number fo this issue already and I just wanted to say thanks to those who added that reaction 🙏 We can then see the issues that have the most "thumbs up" reactions to know which ones are important to the community 👍

@gipscoh
Copy link

gipscoh commented Oct 20, 2021 via email

@tay1orjones tay1orjones modified the milestone: v11 Beta 3 Nov 2, 2021
@gipscoh
Copy link

gipscoh commented Nov 9, 2021

Hi everyone
I found the solution how to set the new value to Multiselect based on initialSelectedValue props:

https://codesandbox.io/s/carbon-design-programmly-setting-value-mfoy6

@galilmori
Copy link

galilmori commented Nov 10, 2021

Hi everyone I found the solution how to set the new value to Multiselect based on initialSelectedValue props:

https://codesandbox.io/s/carbon-design-programmly-setting-value-mfoy6

The thing is that everytime you are updayting the value (this is the proposed workaround from carbon team) you also update your key which rerenders the component. The problem with that when you want to dynamically update your list according to what you choose the component will rerender and the selection overflow menu will close. Also this is a suboptimal way to use react. A component should not rerendered everytime you click on something!

@dezkareid
Copy link
Contributor

dezkareid commented Dec 4, 2021

I have the same issue, to solve this one I change the useSelection hook to include a value property this one is used like a flag to know if component is controlled or uncontrolled by the user.

Apparently is working fine, I would like to be assigned to this issue, you can check the code of my approach on this PR

Screen Shot 2021-12-04 at 17 44 21

@arloduff
Copy link

arloduff commented Nov 8, 2022

Can someone please clarify if this is working, or if it isn't? #10236 makes me think this should be working, but I have the latest carbon-components-react installed (8.16.0 according to the NPM registry) and the selected items are not being updated when I call setSelectedItems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: multiselect hacktoberfest See https://hacktoberfest.com/ package: react carbon-components-react proposal: accepted This request has gone through triaging and we are accepting PR's against it. role: dev 🤖 type: enhancement 💡
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.