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

[Feature Request]: Programmatically control selectedItems in Filterable MultiSelect #10340

Open
1 task done
ask-42 opened this issue Jan 4, 2022 · 11 comments
Open
1 task done
Labels
component: filterable-multiselect component: multiselect needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. 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

@ask-42
Copy link

ask-42 commented Jan 4, 2022

Summary

The non-filterable MultiSelect was enhanced to allow you to pass selectedItems to fully control it (#10236).

It would be nice if the Filterable MultiSelect allowed this as well, as we need this functionality. I currently work around this issue with a hacky solution involving subclassing the component, but I'd prefer not to do that, and it won't be an option anymore once it has been migrated to being a functional component. Right now it only supports initialSelectedItems, but I need full control over the selection even after mounting.

Justification

No response

Desired UX and success metrics

No response

Required functionality

selectedItems can be programmatically controlled.

Specific timeline issues / requests

Before or alongside any release that migrates the component to be functional instead of class-based.

Available extra resources

No response

Code of Conduct

@abbeyhrt abbeyhrt added package: react carbon-components-react and removed status: needs triage 🕵️‍♀️ labels Jan 6, 2022
@jnm2377 jnm2377 added component: multiselect proposal: open This request has gone through triaging. We're determining whether we take this on or not. role: dev 🤖 labels Feb 2, 2022
@abbeyhrt abbeyhrt added proposal: accepted This request has gone through triaging and we are accepting PR's against it. type: contribution 🎁 and removed proposal: open This request has gone through triaging. We're determining whether we take this on or not. labels Feb 21, 2022
@abbeyhrt
Copy link
Contributor

We would love to have this contributed! We think it's a great feature to have and similar to MultiSelect, we would love to help out anyone who would want to contribute this solution!

@mthaak
Copy link

mthaak commented Jul 11, 2022

The extra confusing thing is that since the FilterableMultiSelectProps TypeScript type extends MultiSelectProps in @types/carbon-components-react (see here), the selectedItems prop is present on the FilterableMultiSelect and so you don't get any errors if you provide it. But actually the selectedItems argument is being ignored

This deficiency is preventing me from updating the selected items programmatically after the component has been mounted

@mthaak
Copy link

mthaak commented Jul 11, 2022

This is a fix:

<MultiSelect.Filterable
    ...
    initialSelectedItems={mySelectedItems}
    // A random key enforces the remounting of the component every time the parent is rendered
    key={Math.random()}
/>

But it's not obvious and requires the FilterableMultiSelect to be remounted every time

@sstrubberg
Copy link
Member

Per @tw15egan's comments during Backlog Cleaning this morning. We would need look at mutliselect and see if we can port the changes made in #4812 to filterable multi-select. Possible design guidance based on this. It could be a healthy amount of sprint work, if mutli-select is portable. But if not, it could take much longer.

@sstrubberg sstrubberg moved this to 🥶 Ice Box in Design System Oct 3, 2022
@sstrubberg sstrubberg moved this from Accepted to Icebox in Roadmap Oct 3, 2022
@sstrubberg sstrubberg added the needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. label Oct 3, 2022
@sstrubberg sstrubberg moved this from Icebox to Accepted as community contribution in Roadmap Oct 3, 2022
@sstrubberg sstrubberg moved this from 🥶 Ice Box to 🕵️‍♀️ Triage in Design System Nov 30, 2022
@marconuccetelli
Copy link

@mthaak's solution works for updating data, but it causes the list to scroll up whenever something changes within the component. Any news on this functionality?

@sstrubberg
Copy link
Member

Unfortunately, no movement has been made by the maintainer team on this request. Due to roadmap constraints, we've identified this as work we would love to see the community take up by creating a PR. We'll let you know if anything changes!

@ychavoya
Copy link
Contributor

ychavoya commented Apr 2, 2024

Hi, I'd like to be assigned this issue is possible to work on it, thanks!

@tw15egan
Copy link
Collaborator

@ychavoya would #16139 also resolve this issue?

@ychavoya
Copy link
Contributor

@tw15egan No, the Filterable MultiSelect does not have any implementation on controlled input. I actually ran into the issue that that PR solves by trying to explore this feature

@tw15egan
Copy link
Collaborator

tw15egan commented Apr 12, 2024

Ah, my mistake, @ychavoya; I did not see the distinction that this issue is regarding FilterableMultiselect

@ychavoya
Copy link
Contributor

Hi, just FYI I noticed that the changes from #16147 may add this functionality since it seems to implement the useSelection hook used in the regular Multiselect. It may be worth to check when that PR is done

@sstrubberg sstrubberg moved this from Ready for community implementation to Icebox 🧊 in Roadmap Sep 11, 2024
@sstrubberg sstrubberg moved this to 📋 Backlog in Community Workgroups Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: filterable-multiselect component: multiselect needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. 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
Status: 📋 Backlog
Status: Later 🧊
Development

No branches or pull requests

9 participants