@@ -10,7 +10,7 @@ import {SuiSelectOption} from "./select-option";
1010import { KeyCode } from '../../components/dropdown/dropdown.service' ;
1111import { Subscription } from "rxjs" ;
1212import { SuiDropdownService } from "../dropdown/dropdown.service" ;
13- import { Input , Output } from "@angular/core/src/metadata/directives " ;
13+ import { Input , Output } from "@angular/core" ;
1414import { SuiSearchService } from "../search/search.service" ;
1515import { SuiSelectMultiLabel } from "./multi-select-label" ;
1616
@@ -78,12 +78,20 @@ export class SuiMultiSelect implements AfterContentInit, AfterViewInit {
7878 public placeholder :string = "Select..." ;
7979
8080 @Input ( )
81- public get options ( ) :any {
81+ public get options ( ) :any [ ] {
8282 return this . _searchService . options ;
8383 }
8484
85- public set options ( value :any ) {
85+ public set options ( value :any [ ] ) {
8686 this . _searchService . options = value ;
87+ if ( this . options . length > 0 && this . selectedOptions ) {
88+ this . selectedOptions = this . selectedOptions . map ( so => {
89+ if ( ! this . options . find ( o => o == so ) ) {
90+ return this . options . find ( o => so == this . _searchService . deepValue ( o , this . keyField ) ) ;
91+ }
92+ return so ;
93+ } ) ;
94+ }
8795 }
8896
8997 @Input ( )
@@ -257,8 +265,7 @@ export class SuiMultiSelect implements AfterContentInit, AfterViewInit {
257265 this . selectedOptions = value ;
258266 if ( this . options . length > 0 ) {
259267 this . selectedOptions = this . selectedOptions . map ( so => {
260- let compareValue = this . _searchService . deepValue ( so , this . keyField ) ;
261- return this . options . find ( ( o :any ) => compareValue == o ) ;
268+ return this . options . find ( o => so == this . _searchService . deepValue ( o , this . keyField ) ) ;
262269 } ) ;
263270 }
264271 }
0 commit comments