-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Multi select controlled #10236
Conversation
DCO Assistant Lite bot All contributors have signed the DCO. |
I have read the DCO document and I hereby sign the DCO. |
✔️ 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 |
There was a problem hiding this 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.
<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> |
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
✔️ 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 |
✔️ Deploy Preview for carbon-components-react ready! 🔨 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 |
✔️ 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 |
✔️ 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 |
There was a problem hiding this 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 👍
For those who need a temporary workaround (eg. dont want yet to upgrade carbon), you can force rerender MultiSelect and use |
Closes #4812
Unable to control react/MultiSelect items selected
Changelog
New
Testing / Reviewing
You can see Multiselect/controlled story and see how items are controlled