Skip to content

Commit 5bfe1fa

Browse files
authored
Merge branch 'master' into bpachilova/fix-14135
2 parents 7606924 + 210d53e commit 5bfe1fa

File tree

5 files changed

+99
-5
lines changed

5 files changed

+99
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ All notable changes for each version of this project will be documented in this
3636
### General
3737
- Removed deprecated property `displayDensity`. Size is now controlled only through the custom CSS property `--ig-size`. Refer to the [Update Guide](https://www.infragistics.com/products/ignite-ui-angular/angular/components/general/update-guide) and components documentation for usage details.
3838

39+
### General
40+
- `IgxSimpleCombo`
41+
- **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.
42+
3943
## 17.2.0
4044
### New Features
4145
- `IgxAvatar`

projects/igniteui-angular/migrations/update-18_0_0/index.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ describe(`Update to ${version}`, () => {
3535
beforeEach(() => {
3636
appTree = new UnitTestTree(new EmptyTree());
3737
appTree.create('/angular.json', JSON.stringify(configJson));
38-
appTree.create('/testSrc/styles.scss', '');
38+
appTree.create('/testSrc/styles.scss', `
39+
@use "mockStyles.scss";
40+
@forward something;
41+
`);
3942
});
4043

4144
const migrationName = 'migration-38';
@@ -434,8 +437,12 @@ describe(`Update to ${version}`, () => {
434437

435438
it('should add default CSS rule to set all components to their previous Large defaults', async () => {
436439
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
437-
expect(tree.readContent('/testSrc/styles.scss')).toContain(
440+
expect(tree.readContent('/testSrc/styles.scss')).toEqual(
438441
`
442+
@use "mockStyles.scss";
443+
@forward something;
444+
// Specifies large size for all components to match the previous defaults
445+
// This may not be needed for your project. Please consult https://www.infragistics.com/products/ignite-ui-angular/angular/components/general/update-guide for more details.
439446
:root {
440447
--ig-size: var(--ig-size-large);
441448
}

projects/igniteui-angular/migrations/update-18_0_0/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,23 @@ export default (): Rule => async (host: Tree, context: SchematicContext) => {
100100
}
101101

102102
const content = cssBuffer.toString('utf-8');
103-
const newContent = `
103+
let newContent = `
104104
// Specifies large size for all components to match the previous defaults
105105
// This may not be needed for your project. Please consult https://www.infragistics.com/products/ignite-ui-angular/angular/components/general/update-guide for more details.
106106
:root {
107107
--ig-size: var(--ig-size-large);
108-
}\n` + content;
108+
}\n`;
109+
110+
const lastUse = content.lastIndexOf('@use');
111+
const lastForward = content.lastIndexOf('@forward');
112+
if (lastUse > -1 || lastForward > -1) {
113+
const lastLinePos = Math.max(lastForward, lastUse);
114+
const fragment = content.substring(lastLinePos);
115+
const insertPos = fragment.indexOf(';') + lastLinePos + 1;
116+
newContent = content.substring(0, insertPos) + newContent + content.substring(insertPos + 1);
117+
} else {
118+
newContent = newContent + content;
119+
}
109120

110121
// Write the new content to the CSS file
111122
host.overwrite(stylesPath, newContent);

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,45 @@ describe('IgxSimpleCombo', () => {
17801780
expect(combo.valid).toEqual(IgxInputState.INVALID);
17811781
expect(combo.comboInput.valid).toEqual(IgxInputState.INVALID);
17821782
});
1783+
1784+
it('Should update the model only if a selection is changing otherwise it shoudl be undefiend when the user is filtering in templeted form', fakeAsync(() => {
1785+
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
1786+
let model;
1787+
1788+
combo.open();
1789+
fixture.detectChanges();
1790+
const item2 = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[3];
1791+
item2.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
1792+
fixture.detectChanges();
1793+
model = fixture.componentInstance.values;
1794+
1795+
expect(combo.displayValue).toEqual('Illinois');
1796+
expect(combo.value).toEqual('Illinois');
1797+
expect(model).toEqual('Illinois');
1798+
1799+
combo.deselect();
1800+
fixture.detectChanges();
1801+
model = fixture.componentInstance.values;
1802+
1803+
expect(combo.selection).not.toBeDefined();
1804+
expect(model).toEqual(undefined);
1805+
expect(combo.displayValue).toEqual('');
1806+
1807+
combo.focusSearchInput();
1808+
UIInteractions.simulateTyping('con', input);
1809+
fixture.detectChanges();
1810+
model = fixture.componentInstance.values;
1811+
expect(combo.comboInput.value).toEqual('con');
1812+
expect(model).toEqual(undefined);
1813+
1814+
UIInteractions.triggerKeyDownEvtUponElem('Enter', input.nativeElement);
1815+
fixture.detectChanges();
1816+
model = fixture.componentInstance.values;
1817+
expect(combo.selection).toBeDefined()
1818+
expect(combo.displayValue).toEqual('Wisconsin');
1819+
expect(combo.value).toEqual('Wisconsin');
1820+
expect(model).toEqual('Wisconsin');
1821+
}));
17831822
});
17841823
describe('Reactive form tests: ', () => {
17851824
beforeAll(waitForAsync(() => {
@@ -2036,6 +2075,40 @@ describe('IgxSimpleCombo', () => {
20362075
expect((combo as any).inputGroup.element.nativeElement.classList.contains(CSS_CLASS_INPUT_GROUP_INVALID)).toBe(true);
20372076
expect((combo as any).inputGroup.element.nativeElement.classList.contains(CSS_CLASS_INPUT_GROUP_REQUIRED)).toBe(false);
20382077
}));
2078+
2079+
it('Should update the model only if a selection is changing otherwise it shoudl be undefiend when the user is filtering in reactive form', fakeAsync(() => {
2080+
const form = (fixture.componentInstance as IgxSimpleComboInReactiveFormComponent).comboForm;
2081+
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
2082+
2083+
combo.open();
2084+
fixture.detectChanges();
2085+
const item2 = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[3];
2086+
item2.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
2087+
fixture.detectChanges();
2088+
2089+
expect(combo.displayValue).toEqual('Four');
2090+
expect(combo.value).toEqual(4);
2091+
expect(form.controls['comboValue'].value).toEqual(4);
2092+
2093+
combo.deselect();
2094+
fixture.detectChanges();
2095+
2096+
expect(combo.selection).not.toBeDefined()
2097+
expect(form.controls['comboValue'].value).toEqual(undefined);
2098+
expect(combo.displayValue).toEqual('');
2099+
2100+
combo.focusSearchInput();
2101+
UIInteractions.simulateTyping('on', input);
2102+
fixture.detectChanges();
2103+
expect(combo.comboInput.value).toEqual('on');
2104+
expect(form.controls['comboValue'].value).toEqual(undefined);
2105+
2106+
UIInteractions.triggerKeyDownEvtUponElem('Enter', input.nativeElement);
2107+
expect(combo.selection).toBeDefined()
2108+
expect(combo.displayValue).toEqual('One');
2109+
expect(combo.value).toEqual(1);
2110+
expect(form.controls['comboValue'].value).toEqual(1);
2111+
}));
20392112
});
20402113
});
20412114

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
@@ -282,7 +282,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
282282
if (event !== undefined) {
283283
this.filterValue = this.searchValue = typeof event === 'string' ? event : event.target.value;
284284
}
285-
this._onChangeCallback(this.searchValue);
286285
if (this.collapsed && this.comboInput.focused) {
287286
this.open();
288287
}

0 commit comments

Comments
 (0)