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

Multi select controlled #10236

Merged
merged 15 commits into from
Dec 9, 2021

Conversation

dezkareid
Copy link
Contributor

Closes #4812

Unable to control react/MultiSelect items selected

Changelog

New

  • Add a feature to control selected items on Multilselect

Testing / Reviewing

You can see Multiselect/controlled story and see how items are controlled

@dezkareid dezkareid requested review from a team as code owners December 6, 2021 20:37
@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2021

DCO Assistant Lite bot All contributors have signed the DCO.

@dezkareid
Copy link
Contributor Author

I have read the DCO document and I hereby sign the DCO.

@tay1orjones tay1orjones requested a review from dakahn December 6, 2021 20:44
@netlify
Copy link

netlify bot commented Dec 6, 2021

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: 9674c32

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/61b268106e7eac0007ca3245

😎 Browse the preview: https://deploy-preview-10236--carbon-react-next.netlify.app

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this contribution @dezkareid! Below are a couple of things I noticed at first glance.

I'd like to dig in a bit further on the changes to useSelection and understand more fully what's going on in that logic.

Comment on lines +169 to +180
<Button
onClick={() => {
setSelectedItems([{ id: 'downshift-1-item-0', text: 'Option 1' }]);
}}>
click to select only Option 1
</Button>
<Button
onClick={() => {
setSelectedItems([]);
}}>
click to clear selections
</Button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added these to this PR to make testing a bit easier in the storybook 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@netlify
Copy link

netlify bot commented Dec 6, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: a4e72c9

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61ae75b8c2a03f00072b87c7

😎 Browse the preview: https://deploy-preview-10236--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Dec 6, 2021

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: a4e72c9

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61ae75b89d8402000830a4e3

😎 Browse the preview: https://deploy-preview-10236--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Dec 6, 2021

✔️ Deploy Preview for carbon-components-react ready!

🔨 Explore the source changes: 9674c32

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61b26810ad83e60007726179

😎 Browse the preview: https://deploy-preview-10236--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Dec 6, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: 9674c32

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61b26810eee0180008137455

😎 Browse the preview: https://deploy-preview-10236--carbon-elements.netlify.app

@dezkareid dezkareid requested a review from tay1orjones December 7, 2021 18:52
Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes, this looks great 👍

@dakahn dakahn enabled auto-merge (squash) December 9, 2021 20:35
@dakahn dakahn merged commit 4668c99 into carbon-design-system:main Dec 9, 2021
@fabpico
Copy link
Contributor

fabpico commented Mar 23, 2022

For those who need a temporary workaround (eg. dont want yet to upgrade carbon), you can force rerender MultiSelect and use initialSelectedItems.

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

Successfully merging this pull request may close these issues.

MultiSelect - ability to have more control over and clear selected items
4 participants