Skip to content

Commit 67843d2

Browse files
authored
Merge branch '16.1.x' into bpachilova/fix-14135-16.1.x
2 parents b467848 + 3208f2c commit 67843d2

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ All notable changes for each version of this project will be documented in this
77
- `IgxButtonGroup`:
88
- Reverted cancellable on `selected` and `deselected` events (added in 15.1.24) as it was breaking firing order and related handling.
99

10+
### General
11+
- `IgxSimpleCombo`
12+
- **Behavioral Change** When bound to `ngModel` and `formControlName` directives, the model would not be updated when the user types into the input and will only be updated on selection.
13+
1014
## 16.1.4
1115
### New Features
1216
- `Themes`:

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,45 @@ describe('IgxSimpleCombo', () => {
18091809
expect(combo.valid).toEqual(IgxComboState.INVALID);
18101810
expect(combo.comboInput.valid).toEqual(IgxInputState.INVALID);
18111811
});
1812+
1813+
it('Should update the model only if a selection is changing otherwise it should be undefiend when the user is filtering in templeted form', fakeAsync(() => {
1814+
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
1815+
let model;
1816+
1817+
combo.open();
1818+
fixture.detectChanges();
1819+
const item2 = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[3];
1820+
item2.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
1821+
fixture.detectChanges();
1822+
model = fixture.componentInstance.values;
1823+
1824+
expect(combo.displayValue).toEqual(['Illinois']);
1825+
expect(combo.value).toEqual(['Illinois']);
1826+
expect(model).toEqual('Illinois');
1827+
1828+
combo.deselect();
1829+
fixture.detectChanges();
1830+
model = fixture.componentInstance.values;
1831+
1832+
expect(combo.selection).toEqual([]);
1833+
expect(model).toEqual(undefined);
1834+
expect(combo.displayValue).toEqual([]);
1835+
1836+
combo.focusSearchInput();
1837+
UIInteractions.simulateTyping('con', input);
1838+
fixture.detectChanges();
1839+
model = fixture.componentInstance.values;
1840+
expect(combo.comboInput.value).toEqual('con');
1841+
expect(model).toEqual(undefined);
1842+
1843+
UIInteractions.triggerKeyDownEvtUponElem('Enter', input.nativeElement);
1844+
fixture.detectChanges();
1845+
model = fixture.componentInstance.values;
1846+
expect(combo.selection).toBeDefined()
1847+
expect(combo.displayValue).toEqual(['Wisconsin']);
1848+
expect(combo.value).toEqual(['Wisconsin']);
1849+
expect(model).toEqual('Wisconsin');
1850+
}));
18121851
});
18131852
describe('Reactive form tests: ', () => {
18141853
beforeAll(waitForAsync(() => {
@@ -2026,6 +2065,43 @@ describe('IgxSimpleCombo', () => {
20262065
expect((combo as any).inputGroup.element.nativeElement.classList.contains(CSS_CLASS_INPUT_GROUP_INVALID)).toBe(true);
20272066
expect((combo as any).inputGroup.element.nativeElement.classList.contains(CSS_CLASS_INPUT_GROUP_REQUIRED)).toBe(false);
20282067
}));
2068+
2069+
it('Should update the model only if a selection is changing otherwise it should be undefiend when the user is filtering in reactive form', fakeAsync(() => {
2070+
const form = (fixture.componentInstance as IgxSimpleComboInReactiveFormComponent).comboForm;
2071+
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
2072+
2073+
combo.open();
2074+
fixture.detectChanges();
2075+
2076+
const item2 = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[3];
2077+
item2.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
2078+
fixture.detectChanges();
2079+
2080+
2081+
expect(combo.displayValue).toEqual(['Four']);
2082+
expect(combo.value).toEqual([4]);
2083+
expect(form.controls['comboValue'].value).toEqual(4);
2084+
2085+
combo.deselect();
2086+
fixture.detectChanges();
2087+
2088+
expect(combo.selection).toEqual([]);
2089+
expect(form.controls['comboValue'].value).toEqual(undefined);
2090+
expect(combo.displayValue).toEqual([]);
2091+
2092+
combo.focusSearchInput();
2093+
UIInteractions.simulateTyping('on', input);
2094+
fixture.detectChanges();
2095+
expect(combo.comboInput.value).toEqual('on');
2096+
expect(form.controls['comboValue'].value).toEqual(undefined);
2097+
2098+
combo.select(combo.data[0][combo.valueKey]);
2099+
fixture.detectChanges();
2100+
expect(combo.selection).toBeDefined();
2101+
expect(combo.displayValue).toEqual(['One']);
2102+
expect(combo.value).toEqual([1]);
2103+
expect(form.controls['comboValue'].value).toEqual(1);
2104+
}));
20292105
});
20302106
});
20312107

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
260260
if (event !== undefined) {
261261
this.filterValue = this.searchValue = typeof event === 'string' ? event : event.target.value;
262262
}
263-
this._onChangeCallback(this.searchValue);
264263
if (this.collapsed && this.comboInput.focused) {
265264
this.open();
266265
}

0 commit comments

Comments
 (0)