Skip to content

Commit bbbe08a

Browse files
committed
fix(simple-combo): clear input on blur when bound to remote data
1 parent 82b740a commit bbbe08a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,18 @@ describe('IgxSimpleCombo', () => {
20772077
const selectedItem = combo.data[combo.data.length - 1];
20782078
expect(combo.displayValue).toEqual([`${selectedItem[combo.displayKey]}`]);
20792079
}));
2080+
it('should clear input on blur when bound to remote data and no item is selected', () => {
2081+
input.triggerEventHandler('focus', {});
2082+
fixture.detectChanges();
2083+
2084+
UIInteractions.simulateTyping('pro', input);
2085+
fixture.detectChanges();
2086+
2087+
UIInteractions.triggerEventHandlerKeyDown('Tab', input);
2088+
fixture.detectChanges();
2089+
2090+
expect(combo.comboInput.value).toEqual('');
2091+
});
20802092
});
20812093
});
20822094

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
524524
private clearOnBlur(): void {
525525
if (this.isRemote) {
526526
const searchValue = this.searchValue || this.comboInput.value;
527-
const remoteValue = Object.keys(this._remoteSelection).map(e => this._remoteSelection[e])[0];
528-
if (remoteValue && searchValue !== remoteValue) {
527+
const remoteValue = Object.keys(this._remoteSelection).map(e => this._remoteSelection[e])[0] || '';
528+
if (searchValue !== remoteValue) {
529529
this.clear();
530530
}
531531
return;

0 commit comments

Comments
 (0)