Skip to content

Commit 5eefc36

Browse files
Ivan KitanovIvan Kitanov
authored andcommitted
fix(simple-combo): Adding disableFiltering to simple-combo
1 parent 8911970 commit 5eefc36

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,30 @@ describe('IgxSimpleCombo', () => {
12301230
expect(combo.displayValue).toEqual('Wisconsin');
12311231
});
12321232

1233+
it('should not filter the data when disableFiltering is true', () => {
1234+
combo.disableFiltering = true;
1235+
fixture.detectChanges();
1236+
combo.focusSearchInput();
1237+
expect(combo.filteredData.length).toEqual(combo.data.length);
1238+
1239+
UIInteractions.simulateTyping('con', input);
1240+
expect(combo.comboInput.value).toEqual('con');
1241+
fixture.detectChanges();
1242+
1243+
expect(combo.filteredData.length).toEqual(combo.data.length);
1244+
UIInteractions.triggerEventHandlerKeyDown('Tab', input);
1245+
fixture.detectChanges();
1246+
1247+
combo.disableFiltering = false;
1248+
fixture.detectChanges();
1249+
combo.focusSearchInput();
1250+
expect(combo.filteredData.length).toEqual(combo.data.length);
1251+
UIInteractions.simulateTyping('con', input);
1252+
expect(combo.comboInput.value).toEqual('con');
1253+
fixture.detectChanges();
1254+
expect(combo.filteredData.length).toEqual(2);
1255+
});
1256+
12331257
it('should display the AddItem button when allowCustomValues is true and there is a partial match', fakeAsync(() => {
12341258
fixture.componentInstance.allowCustomValues = true;
12351259
fixture.detectChanges();

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { NgTemplateOutlet } from '@angular/common';
22
import {
33
AfterViewInit, ChangeDetectorRef, Component, DoCheck, ElementRef, EventEmitter, HostListener, Inject, Injector,
4-
Optional, Output, ViewChild, DOCUMENT
4+
Optional, Output, ViewChild, DOCUMENT,
5+
Input,
6+
booleanAttribute
57
} from '@angular/core';
68
import { ControlValueAccessor, FormGroupDirective, NG_VALUE_ACCESSOR } from '@angular/forms';
79
import { takeUntil } from 'rxjs/operators';
@@ -114,9 +116,22 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
114116

115117
private _collapsing = false;
116118

119+
private _disableFiltering = false;
120+
121+
/**
122+
* Enables/disables filtering in the list. The default is `false`.
123+
*/
124+
@Input({ transform: booleanAttribute })
125+
public get disableFiltering(): boolean {
126+
return this._disableFiltering;
127+
}
128+
public set disableFiltering(value: boolean) {
129+
this._disableFiltering = value;
130+
}
131+
117132
/** @hidden @internal */
118133
public get filteredData(): any[] | null {
119-
return this._filteredData;
134+
return this.disableFiltering ? this.data : this._filteredData;
120135
}
121136
/** @hidden @internal */
122137
public set filteredData(val: any[] | null) {
@@ -290,6 +305,9 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
290305
if (this.collapsed && this.comboInput.focused) {
291306
this.open();
292307
}
308+
if (this.disableFiltering) {
309+
return;
310+
}
293311
if (event !== undefined) {
294312
this.filterValue = this.searchValue = typeof event === 'string' ? event : event.target.value;
295313
}

0 commit comments

Comments
 (0)