mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
93.06k stars 32.05k forks source link

[SelectField] [DropDownMenu] Implement multiple select #1956

Closed losogudok closed 7 years ago

losogudok commented 8 years ago

What do you think about multiple select?

chrismcv commented 8 years ago

I think list (and therefore new menus) can do this. SelectField/DropDownMenu don't use the new menu's yet. Is that along the lines of what you were thinking...?

oliviertassinari commented 8 years ago

@chrismcv I think so. I think that we need to updates SelectField and DropDownMenu to use the new Menu component.

stevehu commented 8 years ago

+1. Also allow new entry to be added to support tagging..

Tux1 commented 8 years ago

I am trying to implement a kind of menu containing several checkboxes but it doesn't work well at the moment

Le 13 févr. 2016 à 20:29, Mathias Nilsson notifications@github.com a écrit :

Would love to see this feature.

— Reply to this email directly or view it on GitHub.

nathanmarks commented 8 years ago

@Va1 Please use the github +1 emojis instead of +1ing

FranBran commented 8 years ago

i would love to see a component like the one from MaterializeCSS: multiSelect

support for tagging would also be nice to have!

kkoch986 commented 8 years ago

i accomplished this using this code https://gist.github.com/kkoch986/34a43b79acd460cae527496a5fa6a982 havent tested it much yet but it seems to work ok. would be interested in what everyone else thinks about it.

Sharlaan commented 8 years ago

I think the multiselect feature discussion can be decoupled into 2 sub-features:

  1. the options menu : A great implementation would be the Angular-material "Select Header" At first glance, best component candidate from MaterialUI would be Autocomplete as it would only need a "multiple" prop which would
    • prevent the underlying popover to close onNewRequest()
    • transform the value prop into an array
    • make checkbox appears in MenuItem
    • Alternative to checkboxes: remove selected option from popover list (like with the React Toolbox component)
  2. display the selections This is kinda controversial, i found different views during my searches :
    1. angular-material's select simply concatenates string values directly in the input. This would be incompatible with typing suggestions in the Autocomplete's input. This would explain why they added another input into the menu. Then the selections would be either piling down like with angularMaterial component (fixed width), or a single string concatenating values with an ellipsis hiding overflowing text. I feel this option would not be the nicest as it modifes the overall UI height/width when expanding results
    2. Many e-commerce sites use autocompletes for filtering, i feel their implementation would be better and more flexible : Display of selections is externalized into a textarea below the AutoComplete components, the main input would simply have the placeholder text as default. The selections could then be displayed with chips like with VisualSearch.js A single selections container, coupled to multiple Autocomplete-multiselect components seems a nice idea.

What's your thoughts ?

Sharlaan commented 7 years ago

There are 2 proposed implementations you can use:

... but we are kinda waiting for Material-UI v0.16, major rewrites.

abilashs90 commented 7 years ago

Any updates on this? This is like the most anticipated feature of MUI!

Sharlaan commented 7 years ago

True, i think also it might be the most WANTED component ! :Q___

Here is my current WIP.

I'm wondering if auto-completing the menu options is pertinent when there are only a few ... How about including a props.maxItems above which the AutoCompleteTextField would appear ?

prabhu commented 7 years ago

@sharlaan Your code is quite brilliant. Are you planning to create a component project with that?

Sharlaan commented 7 years ago

Here is my repo

slavab89 commented 7 years ago

@Sharlaan Amazing!! I'm going to try to integrate this into my project and see how it goes.

jagribble commented 7 years ago

@Sharlaan really useful!

DDDDDanica commented 7 years ago

@Sharlaan How do you solve the issue of this line : handleSelection = (name, value) => this.setState({ [name]: value }) It is also listed an example in Material-UI and gave me error of unexpected token =

Sharlaan commented 7 years ago

@ DDDDDanica : Maybe you forgot to specify a name attribute on your component ?

Also (from memory) i remember getting this false error when using static keyword in class in unconfigured IDE...

Can you tell more about the context of your error ?

oliviertassinari commented 7 years ago

@JessThrysoee did an awesome job extending the multiple property of the <Menu /> up to the <SelectField />. We now have three alternatives to address that multi-select problem:

  1. The material-ui-chip-input package that implements something close to what the Material Design specification is suggesting to do. demo
  2. The multiple property, we have an example in the documentation for the <SelectField />. mars-11-2017 15-39-57
  3. The material-ui-superselectfield package that kind of mix the two previous approaches.
Frikster commented 2 years ago

For anyone landing here note that the three solution libraries in the above comment appear to no longer be maintained. Best solution is likely to use MUI's autocomplete with multiple values.