bithost-gmbh / ngx-mat-select-search

Angular component providing an input field for searching / filtering MatSelect options of the Angular Material library.
MIT License
652 stars 132 forks source link

[BUG] Selecting options after filtering will remove selected options #249

Closed croy618 closed 4 years ago

croy618 commented 4 years ago

Describe the bug After clearing a filter that has no matches, currently selected options are removed from the selected list when selecting a filtered item.

To Reproduce

  1. Go to https://stackblitz.com/github/bithost-gmbh/ngx-mat-select-search-example
  2. Scroll down to 'Multiple selection with Select All Checkbox'
  3. Note the already selected options
  4. Click the select
  5. Enter 'zz' in the filter
  6. Click the 'x' to clear the filter
  7. Enter 'Bank A' in the filter
  8. Select Bank A (Switzerland)
  9. Note the previously selected options have been removed

Expected behavior I expect Bank A (Switzerland) to be added to the list of selected options, with none of the currently selected options removed

Screenshots Gif of above https://gfycat.com/viciouscloseflyingfox

Desktop (please complete the following information):

Additional context Step 6 can also be replaced with a highlight all and backspace on the filter, or for some filter strings (step 5) regular backspaces. Some filter strings with no matches such as 'nothing' will not exhibit this behavior when backspaced normally, so this may be related somehow to whether prefix-substrings have any matches.

macjohnny commented 4 years ago

Thanks for reporting this issue. The problem can be reproduced with version 3.0.1. Version 3.0.0 does not show this problem (https://stackblitz.com/github/bithost-gmbh/ngx-mat-select-search-example/tree/3.0.0) I will investigate it and find a fix.

macjohnny commented 4 years ago

fixed with #250, will be released in version 3.0.3 today

begandroide commented 4 years ago

Hello @macjohnny , Im using this lib and i find a bug like this, but a tiny different.

In the Stackblitz of this repo, precisely in mat-select multiple with toggle selection; here is the steps to reproduce it:

  1. Open multiselector with toggle,
  2. Click checkbox toggle all (select all)
  3. Click Checkbox toggle again (unselect all)
  4. Make some search in mat-select, and click one of them
  5. The previous selection is selected, this is a error because previous we unselect all by toggle selection.

Regards

PD: this issue is not present in 3.0.0

begandroide commented 4 years ago

A gif of the issue:

ezgif com-video-to-gif (1)

macjohnny commented 4 years ago

@begandroide thanks for reporting the issue. i created a separate issue #260

begandroide commented 4 years ago

Thank you @macjohnny ! Subscribed to #260.