Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,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: ', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,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 */
Expand Down
Loading