@@ -1481,6 +1481,27 @@ describe('igxCombo', () => {
1481
1481
expectedOutput += ', ' + combo . data [ 9 ] ;
1482
1482
expect ( inputElement . value ) . toEqual ( expectedOutput ) ;
1483
1483
} ) ) ;
1484
+
1485
+ it ( 'Should properly handle selection manipulation through onSelectionChange emit' , fakeAsync ( ( ) => {
1486
+ const fixture = TestBed . createComponent ( IgxComboSampleComponent ) ;
1487
+ fixture . detectChanges ( ) ;
1488
+ const combo = fixture . componentInstance . combo ;
1489
+ // override selection
1490
+ fixture . componentInstance . onSelectionChange = ( event ) => {
1491
+ event . newSelection = [ ] ;
1492
+ } ;
1493
+ combo . toggle ( ) ;
1494
+ tick ( ) ;
1495
+ // No items are initially selected
1496
+ expect ( combo . selectedItems ( ) ) . toEqual ( [ ] ) ;
1497
+ // Select the first 5 items
1498
+ combo . selectItems ( fixture . componentInstance . initData . splice ( 0 , 5 ) ) ;
1499
+ tick ( ) ;
1500
+ fixture . detectChanges ( ) ;
1501
+ tick ( ) ;
1502
+ // onSelectionChange fires and overrides the selection to be [];
1503
+ expect ( combo . selectedItems ( ) ) . toEqual ( [ ] ) ;
1504
+ } ) ) ;
1484
1505
} ) ;
1485
1506
1486
1507
describe ( 'Rendering tests: ' , ( ) => {
@@ -3057,7 +3078,8 @@ class IgxComboScrollTestComponent {
3057
3078
@Component ( {
3058
3079
template : `
3059
3080
<igx-combo #combo [placeholder]="'Location'" [data]='items'
3060
- [filterable]='true' [valueKey]="'field'" [groupKey]="'region'" [width]="'400px'" [allowCustomValues]="true">
3081
+ [filterable]='true' [valueKey]="'field'" [groupKey]="'region'" [width]="'400px'"
3082
+ (onSelectionChange)="onSelectionChange($event)" [allowCustomValues]="true">
3061
3083
<ng-template #itemTemplate let-display let-key="valueKey">
3062
3084
<div class="state-card--simple">
3063
3085
<span class="small-red-circle"></span>
0 commit comments