Skip to content

Commit 2a3d7a0

Browse files
fix(simple-combo): new approach selectionChanging event when input value changes
1 parent 232aebe commit 2a3d7a0

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
@@ -294,7 +294,19 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
294294
this.filterValue = '';
295295
}
296296
if (super.selection.length) {
297-
this.clearSelection();
297+
const args: ISimpleComboSelectionChangingEventArgs = {
298+
newValue: undefined,
299+
oldValue: this.selectedItem,
300+
newSelection: undefined,
301+
oldSelection: this.selection,
302+
displayText: typeof event === 'string' ? event : event?.target?.value,
303+
owner: this,
304+
cancel: false
305+
};
306+
this.selectionChanging.emit(args);
307+
if (!args.cancel) {
308+
this.selectionService.select_items(this.id, [], true);
309+
}
298310
}
299311
// when filtering the focused item should be the first item or the currently selected item
300312
if (!this.dropdown.focusedItem || this.dropdown.focusedItem.id !== this.dropdown.items[0].id) {

0 commit comments

Comments
 (0)