Skip to content

Commit 5e03c5d

Browse files
fix(simple-combo): new approach selectionChanging event when input value changes
1 parent b1b4ebb commit 5e03c5d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ describe('IgxSimpleCombo', () => {
15571557
expect(spy).toHaveBeenCalledTimes(1);
15581558
}));
15591559

1560-
it('should emit selectionChanging event when input value changes and input loses focus', () => {
1560+
it('should emit selectionChanging event when input value changes', () => {
15611561
spyOn(combo.selectionChanging, 'emit').and.callThrough();
15621562
fixture.detectChanges();
15631563

@@ -1591,7 +1591,7 @@ describe('IgxSimpleCombo', () => {
15911591
},
15921592
newSelection: undefined,
15931593
owner: combo,
1594-
displayText: "",
1594+
displayText: "z",
15951595
cancel: false
15961596
});
15971597
});

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,19 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
292292
this.filterValue = '';
293293
}
294294
if (super.selection.length) {
295-
this.clearSelection();
295+
const args: ISimpleComboSelectionChangingEventArgs = {
296+
newValue: undefined,
297+
oldValue: this.selectedItem,
298+
newSelection: undefined,
299+
oldSelection: this.selection,
300+
displayText: typeof event === 'string' ? event : event?.target?.value,
301+
owner: this,
302+
cancel: false
303+
};
304+
this.selectionChanging.emit(args);
305+
if (!args.cancel) {
306+
this.selectionService.select_items(this.id, [], true);
307+
}
296308
}
297309
// when filtering the focused item should be the first item or the currently selected item
298310
if (!this.dropdown.focusedItem || this.dropdown.focusedItem.id !== this.dropdown.items[0].id) {

0 commit comments

Comments
 (0)