@@ -2342,6 +2342,55 @@ describe('igxCombo', () => {
23422342 expect ( combo . value ) . toEqual ( [ ] ) ;
23432343 expect ( combo . displayValue ) . toEqual ( 'Selected Count: 0' ) ;
23442344 } ) ;
2345+ it ( 'should handle selection for combo with array type value key correctly - issue #14103' , ( ) => {
2346+ fixture = TestBed . createComponent ( ComboArrayTypeValueKeyComponent ) ;
2347+ fixture . detectChanges ( ) ;
2348+ combo = fixture . componentInstance . combo ;
2349+ input = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_COMBO_INPUTGROUP } ` ) ) ;
2350+ const items = fixture . componentInstance . items ;
2351+ expect ( combo ) . toBeDefined ( ) ;
2352+
2353+ const selectionSpy = spyOn ( combo . selectionChanging , 'emit' ) ;
2354+ let expectedResults : IComboSelectionChangingEventArgs = {
2355+ newValue : [ combo . data [ 1 ] [ combo . valueKey ] ] ,
2356+ oldValue : [ ] ,
2357+ newSelection : [ combo . data [ 1 ] ] ,
2358+ oldSelection : [ ] ,
2359+ added : [ combo . data [ 1 ] ] ,
2360+ removed : [ ] ,
2361+ event : undefined ,
2362+ owner : combo ,
2363+ displayText : `${ combo . data [ 1 ] [ combo . displayKey ] } ` ,
2364+ cancel : false
2365+ } ;
2366+
2367+ let expectedDisplayText = items [ 1 ] [ combo . displayKey ] ;
2368+ combo . select ( [ fixture . componentInstance . items [ 1 ] . value ] ) ;
2369+ fixture . detectChanges ( ) ;
2370+
2371+ expect ( selectionSpy ) . toHaveBeenCalledWith ( expectedResults ) ;
2372+ expect ( input . nativeElement . value ) . toEqual ( expectedDisplayText ) ;
2373+
2374+ expectedDisplayText = `${ items [ 1 ] [ combo . displayKey ] } , ${ items [ 2 ] [ combo . displayKey ] } ` ;
2375+ expectedResults = {
2376+ newValue : [ combo . data [ 1 ] [ combo . valueKey ] , combo . data [ 2 ] [ combo . valueKey ] ] ,
2377+ oldValue : [ combo . data [ 1 ] [ combo . valueKey ] ] ,
2378+ newSelection : [ combo . data [ 1 ] , combo . data [ 2 ] ] ,
2379+ oldSelection : [ combo . data [ 1 ] ] ,
2380+ added : [ combo . data [ 2 ] ] ,
2381+ removed : [ ] ,
2382+ event : undefined ,
2383+ owner : combo ,
2384+ displayText : expectedDisplayText ,
2385+ cancel : false
2386+ } ;
2387+
2388+ combo . select ( [ items [ 2 ] . value ] ) ;
2389+ fixture . detectChanges ( ) ;
2390+
2391+ expect ( selectionSpy ) . toHaveBeenCalledWith ( expectedResults ) ;
2392+ expect ( input . nativeElement . value ) . toEqual ( expectedDisplayText ) ;
2393+ } ) ;
23452394 } ) ;
23462395 describe ( 'Grouping tests: ' , ( ) => {
23472396 beforeEach ( ( ) => {
@@ -3797,3 +3846,32 @@ export class IgxComboBindingDataAfterInitComponent implements AfterViewInit {
37973846 } , 1000 ) ;
37983847 }
37993848}
3849+
3850+ @Component ( {
3851+ template : `
3852+ <igx-combo [data]="items" valueKey="value" displayKey="item"></igx-combo>` ,
3853+ standalone : true ,
3854+ imports : [ IgxComboComponent ]
3855+ } )
3856+ export class ComboArrayTypeValueKeyComponent {
3857+ @ViewChild ( IgxComboComponent , { read : IgxComboComponent , static : true } )
3858+ public combo : IgxComboComponent ;
3859+ public items : any [ ] = [ ] ;
3860+
3861+ constructor ( ) {
3862+ this . items = [
3863+ {
3864+ item : "Item1" ,
3865+ value : [ 1 , 2 , 3 ]
3866+ } ,
3867+ {
3868+ item : "Item2" ,
3869+ value : [ 4 , 5 , 6 ]
3870+ } ,
3871+ {
3872+ item : "Item3" ,
3873+ value : [ 7 , 8 , 9 ]
3874+ }
3875+ ] ;
3876+ }
3877+ }
0 commit comments