@@ -2343,6 +2343,55 @@ describe('igxCombo', () => {
23432343 expect ( combo . value ) . toEqual ( [ ] ) ;
23442344 expect ( combo . displayValue ) . toEqual ( 'Selected Count: 0' ) ;
23452345 } ) ;
2346+ it ( 'should handle selection for combo with array type value key correctly - issue #14103' , ( ) => {
2347+ fixture = TestBed . createComponent ( ComboArrayTypeValueKeyComponent ) ;
2348+ fixture . detectChanges ( ) ;
2349+ combo = fixture . componentInstance . combo ;
2350+ input = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_COMBO_INPUTGROUP } ` ) ) ;
2351+ const items = fixture . componentInstance . items ;
2352+ expect ( combo ) . toBeDefined ( ) ;
2353+
2354+ const selectionSpy = spyOn ( combo . selectionChanging , 'emit' ) ;
2355+ let expectedResults : IComboSelectionChangingEventArgs = {
2356+ newValue : [ combo . data [ 1 ] [ combo . valueKey ] ] ,
2357+ oldValue : [ ] ,
2358+ newSelection : [ combo . data [ 1 ] ] ,
2359+ oldSelection : [ ] ,
2360+ added : [ combo . data [ 1 ] ] ,
2361+ removed : [ ] ,
2362+ event : undefined ,
2363+ owner : combo ,
2364+ displayText : `${ combo . data [ 1 ] [ combo . displayKey ] } ` ,
2365+ cancel : false
2366+ } ;
2367+
2368+ let expectedDisplayText = items [ 1 ] [ combo . displayKey ] ;
2369+ combo . select ( [ fixture . componentInstance . items [ 1 ] . value ] ) ;
2370+ fixture . detectChanges ( ) ;
2371+
2372+ expect ( selectionSpy ) . toHaveBeenCalledWith ( expectedResults ) ;
2373+ expect ( input . nativeElement . value ) . toEqual ( expectedDisplayText ) ;
2374+
2375+ expectedDisplayText = `${ items [ 1 ] [ combo . displayKey ] } , ${ items [ 2 ] [ combo . displayKey ] } ` ;
2376+ expectedResults = {
2377+ newValue : [ combo . data [ 1 ] [ combo . valueKey ] , combo . data [ 2 ] [ combo . valueKey ] ] ,
2378+ oldValue : [ combo . data [ 1 ] [ combo . valueKey ] ] ,
2379+ newSelection : [ combo . data [ 1 ] , combo . data [ 2 ] ] ,
2380+ oldSelection : [ combo . data [ 1 ] ] ,
2381+ added : [ combo . data [ 2 ] ] ,
2382+ removed : [ ] ,
2383+ event : undefined ,
2384+ owner : combo ,
2385+ displayText : expectedDisplayText ,
2386+ cancel : false
2387+ } ;
2388+
2389+ combo . select ( [ items [ 2 ] . value ] ) ;
2390+ fixture . detectChanges ( ) ;
2391+
2392+ expect ( selectionSpy ) . toHaveBeenCalledWith ( expectedResults ) ;
2393+ expect ( input . nativeElement . value ) . toEqual ( expectedDisplayText ) ;
2394+ } ) ;
23462395 } ) ;
23472396 describe ( 'Grouping tests: ' , ( ) => {
23482397 beforeEach ( ( ) => {
@@ -3768,3 +3817,32 @@ export class IgxComboBindingDataAfterInitComponent implements AfterViewInit {
37683817 } , 1000 ) ;
37693818 }
37703819}
3820+
3821+ @Component ( {
3822+ template : `
3823+ <igx-combo [data]="items" valueKey="value" displayKey="item"></igx-combo>` ,
3824+ standalone : true ,
3825+ imports : [ IgxComboComponent ]
3826+ } )
3827+ export class ComboArrayTypeValueKeyComponent {
3828+ @ViewChild ( IgxComboComponent , { read : IgxComboComponent , static : true } )
3829+ public combo : IgxComboComponent ;
3830+ public items : any [ ] = [ ] ;
3831+
3832+ constructor ( ) {
3833+ this . items = [
3834+ {
3835+ item : "Item1" ,
3836+ value : [ 1 , 2 , 3 ]
3837+ } ,
3838+ {
3839+ item : "Item2" ,
3840+ value : [ 4 , 5 , 6 ]
3841+ } ,
3842+ {
3843+ item : "Item3" ,
3844+ value : [ 7 , 8 , 9 ]
3845+ }
3846+ ] ;
3847+ }
3848+ }
0 commit comments