Sharlaan / material-ui-superselectfield

multiselection autocomplete dropdown component for Material-UI
https://sharlaan.github.io/material-ui-superselectfield
MIT License
266 stars 92 forks source link

[Feature] Option to keep the autocomplete filter after selecting an item #82

Closed THMKAE closed 6 years ago

THMKAE commented 6 years ago

Hey guys,

we're currently working with items that can have a category and the user requires to search within your component for values or categories.

It works like a charm except for one thing: The current implementation clears the textfield after selecting an item. This means that the user will need to type in that category every single time, instead of typing once and selecting all relevant items.

We can get whatever is in the search field with the onAutoCompleteTyping, but there is no way to set the search value (or we missed that somewhere).

My suggestion is to add a property (like keepSearchOnSelect) that will skip the clearTextField() if set (in multiple mode of course). This will keep the current filter and the user is no longer needed to re-type that category.

What do you guys think about this?

Sharlaan commented 6 years ago

Ok thanks for the suggestion.

I started implementing a solutionbut there is a side effect i would like you to tell me if that's ok:

  1. type your search term
  2. the items list gets filtered according to the autocomplete filtering logic
  3. on item selection, 2 cases can happen:
    3.a (previous behavior) the autocomplete field is reseted and focused again, The list gets unfiltered accordingly.
    3.b (with keepSearchOnSelect) the autocomplete field is focused without reseting. The list stays filtered. In this case, user will have to modify the search term to get more values...

I've deployed a demo in CodeExample4, please check it.

is the bolded part a problem for your usecase ?

THMKAE commented 6 years ago

Thanks a lot!

No, it's not a problem at all, it is just as we'd like to have it.

fredericgrati commented 6 years ago

This feature would be great !

And its works perfectly as intended on your CodeExample4.

Sharlaan commented 6 years ago

ok version 1.7.0 released, please check it out ^^

THMKAE commented 6 years ago

@Sharlaan Works perfectly, thanks a lot!