Skip to content

Commit fbfe2d9

Browse files
probert94macjohnny
andauthored
fix selection of different instances of same object when using multiple (#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>
1 parent b6b6ba0 commit fbfe2d9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/app/mat-select-search/mat-select-search.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ export class MatSelectSearchComponent implements OnInit, OnDestroy, AfterViewIni
550550
}
551551
const optionValues = this.matSelect.options.map(option => option.value);
552552
this.previousSelectedValues.forEach(previousValue => {
553-
if (values.indexOf(previousValue) === -1 && optionValues.indexOf(previousValue) === -1) {
553+
if (!values.some(v => this.matSelect.compareWith(v, previousValue))
554+
&& !optionValues.some(v => this.matSelect.compareWith(v, previousValue))) {
554555
// if a value that was selected before is deselected and not found in the options, it was deselected
555556
// due to the filtering, so we restore it.
556557
values.push(previousValue);

0 commit comments

Comments
 (0)