Skip to content

Commit 6648247

Browse files
KatrinhanastasovChronosSF
authored
fix(ISelectionEventArgs): Fix oldSelection when the value is undefined (#12240)
* fix(select): fix oldSelection when the value is undefined * test(igxSelect): fix failing tests Co-authored-by: Hristo <[email protected]> Co-authored-by: Stamen Stoychev <[email protected]>
1 parent 6423d29 commit 6648247

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

projects/igniteui-angular/src/lib/select/select.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component, ViewChild, DebugElement, OnInit, ElementRef } from '@angular
33
import { TestBed, tick, fakeAsync, waitForAsync } from '@angular/core/testing';
44
import { FormsModule, UntypedFormGroup, UntypedFormBuilder, UntypedFormControl, Validators, ReactiveFormsModule, NgForm, NgControl } from '@angular/forms';
55
import { By } from '@angular/platform-browser';
6-
import { IgxDropDownModule, IgxDropDownItemComponent } from '../drop-down/public_api';
6+
import { IgxDropDownModule, IgxDropDownItemComponent, IgxDropDownItemBaseDirective } from '../drop-down/public_api';
77
import { IgxIconModule } from '../icon/public_api';
88
import { IgxInputGroupModule, IgxHintDirective } from '../input-group/public_api';
99
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@@ -1205,7 +1205,7 @@ describe('igxSelect', () => {
12051205
spyOn(select.selectionChanging, 'emit');
12061206
spyOn(select, 'selectItem').and.callThrough();
12071207
const args: ISelectionEventArgs = {
1208-
oldSelection: undefined,
1208+
oldSelection: <IgxDropDownItemBaseDirective>{},
12091209
newSelection: selectedItem,
12101210
cancel: false
12111211
};
@@ -1239,7 +1239,7 @@ describe('igxSelect', () => {
12391239
spyOn(select.selectionChanging, 'emit');
12401240
spyOn(select, 'selectItem').and.callThrough();
12411241
const args: ISelectionEventArgs = {
1242-
oldSelection: undefined,
1242+
oldSelection: <IgxDropDownItemBaseDirective>{},
12431243
newSelection: selectedItem,
12441244
cancel: false
12451245
};
@@ -1269,7 +1269,7 @@ describe('igxSelect', () => {
12691269
spyOn(select.selectionChanging, 'emit');
12701270
spyOn(select, 'selectItem').and.callThrough();
12711271
const args: ISelectionEventArgs = {
1272-
oldSelection: undefined,
1272+
oldSelection: <IgxDropDownItemBaseDirective>{},
12731273
newSelection: selectedItem,
12741274
cancel: false
12751275
};
@@ -1341,7 +1341,7 @@ describe('igxSelect', () => {
13411341
let selectedItem = select.items[4];
13421342
spyOn(select.selectionChanging, 'emit');
13431343
const args: ISelectionEventArgs = {
1344-
oldSelection: undefined,
1344+
oldSelection: <IgxDropDownItemBaseDirective>{},
13451345
newSelection: selectedItem,
13461346
cancel: false
13471347
};

projects/igniteui-angular/src/lib/select/select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
363363

364364
/** @hidden @internal */
365365
public selectItem(newSelection: IgxDropDownItemBaseDirective, event?) {
366-
const oldSelection = this.selectedItem;
366+
const oldSelection = this.selectedItem ?? <IgxDropDownItemBaseDirective>{};
367367

368368
if (newSelection === null || newSelection.disabled || newSelection.isHeader) {
369369
return;

0 commit comments

Comments
 (0)