Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ All notable changes for each version of this project will be documented in this
- Removed `leftButtonColor`, `leftButtonBackgroundColor` `rightButtonColor`, and `rightButtonBackgroundColor` properties.
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
- Enhanced the advanced filtering to emit the `filtering` event when filters are applied.

### General
- `IgxSimpleCombo`
- **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.


## 17.1.0
### New Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,45 @@ describe('IgxSimpleCombo', () => {
expect(combo.valid).toEqual(IgxInputState.INVALID);
expect(combo.comboInput.valid).toEqual(IgxInputState.INVALID);
});

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(() => {
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
let model;

combo.open();
fixture.detectChanges();
const item2 = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[3];
item2.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
fixture.detectChanges();
model = fixture.componentInstance.values;

expect(combo.displayValue).toEqual('Illinois');
expect(combo.value).toEqual('Illinois');
expect(model).toEqual('Illinois');

combo.deselect();
fixture.detectChanges();
model = fixture.componentInstance.values;

expect(combo.selection).not.toBeDefined();
expect(model).toEqual(undefined);
expect(combo.displayValue).toEqual('');

combo.focusSearchInput();
UIInteractions.simulateTyping('con', input);
fixture.detectChanges();
model = fixture.componentInstance.values;
expect(combo.comboInput.value).toEqual('con');
expect(model).toEqual(undefined);

UIInteractions.triggerKeyDownEvtUponElem('Enter', input.nativeElement);
fixture.detectChanges();
model = fixture.componentInstance.values;
expect(combo.selection).toBeDefined()
expect(combo.displayValue).toEqual('Wisconsin');
expect(combo.value).toEqual('Wisconsin');
expect(model).toEqual('Wisconsin');
}));
});
describe('Reactive form tests: ', () => {
beforeAll(waitForAsync(() => {
Expand Down Expand Up @@ -2068,6 +2107,40 @@ describe('IgxSimpleCombo', () => {
expect((combo as any).inputGroup.element.nativeElement.classList.contains(CSS_CLASS_INPUT_GROUP_INVALID)).toBe(true);
expect((combo as any).inputGroup.element.nativeElement.classList.contains(CSS_CLASS_INPUT_GROUP_REQUIRED)).toBe(false);
}));

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(() => {
const form = (fixture.componentInstance as IgxSimpleComboInReactiveFormComponent).comboForm;
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));

combo.open();
fixture.detectChanges();
const item2 = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[3];
item2.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
fixture.detectChanges();

expect(combo.displayValue).toEqual('Four');
expect(combo.value).toEqual(4);
expect(form.controls['comboValue'].value).toEqual(4);

combo.deselect();
fixture.detectChanges();

expect(combo.selection).not.toBeDefined()
expect(form.controls['comboValue'].value).toEqual(undefined);
expect(combo.displayValue).toEqual('');

combo.focusSearchInput();
UIInteractions.simulateTyping('on', input);
fixture.detectChanges();
expect(combo.comboInput.value).toEqual('on');
expect(form.controls['comboValue'].value).toEqual(undefined);

UIInteractions.triggerKeyDownEvtUponElem('Enter', input.nativeElement);
expect(combo.selection).toBeDefined()
expect(combo.displayValue).toEqual('One');
expect(combo.value).toEqual(1);
expect(form.controls['comboValue'].value).toEqual(1);
}));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
if (event !== undefined) {
this.filterValue = this.searchValue = typeof event === 'string' ? event : event.target.value;
}
this._onChangeCallback(this.searchValue);
if (this.collapsed && this.comboInput.focused) {
this.open();
}
Expand Down