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

Uncontrolled MultiSelect example? #3429

Closed
zachkirsch opened this issue Mar 19, 2019 · 6 comments
Closed

Uncontrolled MultiSelect example? #3429

zachkirsch opened this issue Mar 19, 2019 · 6 comments

Comments

@zachkirsch
Copy link
Contributor

zachkirsch commented Mar 19, 2019

Environment

  • Package version(s):
    • "@blueprintjs/core": "^3.8.0",
    • "@blueprintjs/icons": "^3.6.0",
    • "@blueprintjs/select": "^3.7.0",
  • Browser and OS versions: OSX 10.14.3, Chrome 73.0.3683.75

Question

Hi!

I'm trying to get an uncontrolled MultiSelect working, but haven't had much luck. Is there an example of one somewhere?

Here's what I've got. Am I missing something obvious? Is specifying the onClick and active in the MenuItem even necessary?

<MultiSelect
    items={["A", "B", "C"]}
    itemRenderer={(item, { modifiers, handleClick }) =>
        <MenuItem
            key={item}
            text={item}
            onClick={handleClick}
            active={modifiers.active}
        />
    }
    onItemSelect={() => {}}
    tagRenderer={item => item}
/>

This is what renders:

multiselect

Thanks!

@adidahiya
Copy link
Contributor

The example in the docs is actually uncontrolled but it might be a little hard to understand because it does much more than the most basic example usage of the component. Your code looks fine; you do need to set onClick and active on the MenuItem like you are doing. Can you try posting a minimal bug repro using the codesandbox link in the README?

@zachkirsch
Copy link
Contributor Author

Thanks for the quick reply!

I thought that the films array in the MultiSelectExample's state was controlling the MultiSelect.

Here's a link to a repro on the sandbox: https://codesandbox.io/s/1vv1l03j2j

@richwandell
Copy link

richwandell commented Jan 11, 2021

I am running into this same issue today. Was there a resolution?

@adidahiya
Copy link
Contributor

@richwandell this is a pretty old issue, can you please create a new one and share a code sandbox of your problem?

@rrramani1230
Copy link

rrramani1230 commented Feb 11, 2022

Did anyone get this to work. I wonder why the MultiSelect looks like a singleselect. Are there certain props that are not required but needed for the mutliselect to work @zachkirsch @adidahiya

@rrramani1230
Copy link

The answer to this is that you need the selectedItems prop along with the tagRender prop for it to Render. Please don't spent as much time on this as I did finding this out :(

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

4 participants