skratchdot / react-bootstrap-multiselect

A multiselect component for react (with bootstrap). This is a react port of bootstrap-multiselect.
http://projects.skratchdot.com/react-bootstrap-multiselect/
Other
119 stars 61 forks source link

Filter text clears on state change #81

Open darkestmon opened 6 years ago

darkestmon commented 6 years ago

To replicate:

  1. Create a multiselect with filter
  2. Add a setState on onChange
  3. Run
  4. Write something on the filter box
  5. Click an item Expected: multiselect should still be filtered What happens: filter is cleared and multiselect lists all items

I'm guessing since the setState forces a render of the component, the filter box is back to default empty state.

Tried a work around stated in the bootstrap-multiselect site: http://davidstutz.de/bootstrap-multiselect/#further-examples

$('#file-box-wrapper li.multiselect-filter input').val(this.filterKeyword).trigger('keydown');

text is placed in the filterbox but it does not update the list.

darkestmon commented 6 years ago

On a deeper look, looks like bootstrap-multiselect itself doesn't allow initialization of filter box. This might be a bigger issue to fix.