You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In mat-select-search.component.ts#L552, the previously selected values are restored, if they have been removed by the new filter.
However, the used logic does not use the compareWith-function of the mat-select and so different instances of the same object cause problems.
In my case, if I search for a value I make a request to the server, resulting in new instances of the objects. If I deselect an already selected object, it won't be removed. Additionally, selected objects, which match the current search term, are added again, resulting in two instances being part of the value.
…ple` (#216)
* #215: fix selection of different instances of same object when using `multiple`
* Apply suggestions from code review
Co-authored-by: Esteban Gehring <esteban.gehring@gmail.com>
Describe the bug
In mat-select-search.component.ts#L552, the previously selected values are restored, if they have been removed by the new filter.
However, the used logic does not use the
compareWith
-function of themat-select
and so different instances of the same object cause problems.In my case, if I search for a value I make a request to the server, resulting in new instances of the objects. If I deselect an already selected object, it won't be removed. Additionally, selected objects, which match the current search term, are added again, resulting in two instances being part of the value.
To Reproduce
Here is a stackblitz based on ngx-mat-select-search-example
Bank A (Switzerland)
andBank B (Switzerland)
).Switzerland
Bank A (Switzerland)
Selected Banks
Bank A (Switzerland)
is still selected,Bank B (Switzerland)
is selected twice.Expected behavior
The
mat-select-search
should use the providedcompareWith
-Function to check if two objects are the same.Additional Information
It should be enough to change mat-select-search#L553 from
to
The text was updated successfully, but these errors were encountered: