From dbc2e711c61359552ced284e59c3bb10b505ed4f Mon Sep 17 00:00:00 2001 From: georgianastasov Date: Fri, 20 Feb 2026 10:42:12 +0200 Subject: [PATCH] fix(simple-combo): prevent simple combo from clearing on blur --- .../simple-combo.component.spec.ts | 28 +++++++++++++++++++ .../simple-combo/simple-combo.component.ts | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts b/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts index b031242f457..4b9c4616c27 100644 --- a/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts +++ b/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts @@ -2231,6 +2231,34 @@ describe('IgxSimpleCombo', () => { expect(document.activeElement).not.toBe(input.nativeElement); })); + + it('should sync searchValue/filterValue on writeValue and keep selection on blur', fakeAsync(() => { + combo.searchValue = combo.filterValue = 'zzz'; + + combo.writeValue('Connecticut'); + tick(); + fixture.detectChanges(); + + expect(combo.displayValue).toEqual('Connecticut'); + expect(combo.searchValue).toEqual('Connecticut'); + expect(combo.filterValue).toEqual('Connecticut'); + + combo.close(); + tick(); + fixture.detectChanges(); + + input.triggerEventHandler('focus', {}); + fixture.detectChanges(); + + UIInteractions.triggerEventHandlerKeyDown('Tab', input); + tick(); + fixture.detectChanges(); + + expect(combo.selection).toBeDefined(); + expect(combo.selection.field).toEqual('Connecticut'); + expect(combo.displayValue).toEqual('Connecticut'); + expect(input.nativeElement.value).toEqual('Connecticut'); + })); }); describe('Form control tests: ', () => { diff --git a/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts b/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts index 04628a45ca3..d618ce63b2b 100644 --- a/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts +++ b/projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts @@ -216,7 +216,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co this.cdr.markForCheck(); this._displayValue = this.createDisplayText(super.selection, oldSelection); this._value = this.valueKey ? super.selection.map(item => item[this.valueKey]) : super.selection; - this.filterValue = this._displayValue?.toString() || ''; + this.searchValue = this.filterValue = this._displayValue?.toString() || ''; } /** @hidden @internal */