Skip to content

Commit 5b24585

Browse files
authored
Merge pull request #16939 from IgniteUI/ganastasov/fix-16897-master
fix(simple-combo): prevent simple combo from clearing on blur - master
2 parents 2bae7f5 + 587a361 commit 5b24585

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,34 @@ describe('IgxSimpleCombo', () => {
21262126

21272127
expect(document.activeElement).not.toBe(input.nativeElement);
21282128
}));
2129+
2130+
it('should sync searchValue/filterValue on writeValue and keep selection on blur', fakeAsync(() => {
2131+
combo.searchValue = combo.filterValue = 'zzz';
2132+
2133+
combo.writeValue('Connecticut');
2134+
tick();
2135+
fixture.detectChanges();
2136+
2137+
expect(combo.displayValue).toEqual('Connecticut');
2138+
expect(combo.searchValue).toEqual('Connecticut');
2139+
expect(combo.filterValue).toEqual('Connecticut');
2140+
2141+
combo.close();
2142+
tick();
2143+
fixture.detectChanges();
2144+
2145+
input.triggerEventHandler('focus', {});
2146+
fixture.detectChanges();
2147+
2148+
UIInteractions.triggerEventHandlerKeyDown('Tab', input);
2149+
tick();
2150+
fixture.detectChanges();
2151+
2152+
expect(combo.selection).toBeDefined();
2153+
expect(combo.selection.field).toEqual('Connecticut');
2154+
expect(combo.displayValue).toEqual('Connecticut');
2155+
expect(input.nativeElement.value).toEqual('Connecticut');
2156+
}));
21292157
});
21302158

21312159
describe('Form control tests: ', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
187187
this.cdr.markForCheck();
188188
this._displayValue = this.createDisplayText(super.selection, oldSelection);
189189
this._value = this.valueKey ? super.selection.map(item => item[this.valueKey]) : super.selection;
190-
this.filterValue = this._displayValue?.toString() || '';
190+
this.searchValue = this.filterValue = this._displayValue?.toString() || '';
191191
}
192192

193193
/** @hidden @internal */

0 commit comments

Comments
 (0)