Skip to content

Commit 1689214

Browse files
fix(simple-combo): do not filter on enter & closed; clean up
1 parent af35161 commit 1689214

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[attr.aria-expanded]="!this.dropdown.collapsed" [attr.aria-controls]="this.dropdown.listId"
1818
[attr.aria-labelledby]="this.ariaLabelledBy || this.label?.id || this.placeholder"
1919
[attr.placeholder]="placeholder" [disabled]="disabled" [igxTextSelection]="!composing"
20-
(focus)="onFocus()" (input)="handleInputChange($event)" (click)="handleInputClick()"
20+
(input)="handleInputChange($event)" (click)="handleInputClick()"
2121
(keyup)="handleKeyUp($event)" (keydown)="handleKeyDown($event)" (blur)="onBlur()"/>
2222

2323
<ng-container ngProjectAs="igx-suffix">
@@ -62,7 +62,7 @@
6262
[tabindex]="dropdown.collapsed ? -1 : 0" [attr.id]="dropdown.id"
6363
[attr.aria-activedescendant]="this.activeDescendant"
6464
(focus)="dropdown.onFocus()" (keydown)="handleItemKeyDown($event)">
65-
<igx-combo-item [role]="item?.isHeader? 'group' : 'option'" [singleMode]="true"
65+
<igx-combo-item [role]="item?.isHeader? 'group' : 'option'" [singleMode]="true"
6666
[itemHeight]="itemHeight" (click)="handleItemClick()" *igxFor="let item of data
6767
| comboFiltering:filterValue:displayKey:filteringOptions:filterFunction
6868
| comboGrouping:groupKey:valueKey:groupSortingDirection;

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

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
9494

9595
private _updateInput = true;
9696

97-
// stores the last filtered value - move to common?
98-
private _internalFilter = '';
99-
10097
private _collapsing = false;
10198

10299
/** @hidden @internal */
@@ -185,9 +182,9 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
185182
const oldSelection = this.selection;
186183
this.selectionService.select_items(this.id, this.isValid(value) ? [value] : [], true);
187184
this.cdr.markForCheck();
188-
this._displayValue = this.createDisplayText(this.selection, oldSelection);
189-
this._value = this.valueKey ? this.selection.map(item => item[this.valueKey]) : this.selection;
190-
this.filterValue = this._internalFilter = this._displayValue?.toString();
185+
this._displayValue = this.createDisplayText(super.selection, oldSelection);
186+
this._value = this.valueKey ? super.selection.map(item => item[this.valueKey]) : super.selection;
187+
this.filterValue = this._displayValue?.toString() || '';
191188
}
192189

193190
/** @hidden @internal */
@@ -225,7 +222,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
225222
if (this.composing) {
226223
this.comboInput.focus();
227224
}
228-
this._internalFilter = this.comboInput.value;
229225
});
230226
this.dropdown.closing.pipe(takeUntil(this.destroy$)).subscribe((args) => {
231227
if (args.cancel) {
@@ -239,9 +235,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
239235
}
240236
this.comboInput.focus();
241237
});
242-
this.dropdown.closed.pipe(takeUntil(this.destroy$)).subscribe(() => {
243-
this.filterValue = this._internalFilter = this.comboInput.value;
244-
});
245238

246239
// in reactive form the control is not present initially
247240
// and sets the selection to an invalid value in writeValue method
@@ -265,7 +258,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
265258
/** @hidden @internal */
266259
public override handleInputChange(event?: any): void {
267260
if (event !== undefined) {
268-
this.filterValue = this._internalFilter = this.searchValue = typeof event === 'string' ? event : event.target.value;
261+
this.filterValue = this.searchValue = typeof event === 'string' ? event : event.target.value;
269262
}
270263
this._onChangeCallback(this.searchValue);
271264
if (this.collapsed && this.comboInput.focused) {
@@ -303,15 +296,12 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
303296
if (filtered === null || filtered === undefined) {
304297
return;
305298
}
306-
if (!this.dropdown.collapsed) {
307-
this.select(this.dropdown.focusedItem.itemID);
308-
event.preventDefault();
309-
event.stopPropagation();
310-
this.close();
311-
}
299+
this.select(this.dropdown.focusedItem.itemID);
300+
event.preventDefault();
301+
event.stopPropagation();
302+
this.close();
312303
// manually trigger text selection as it will not be triggered during editing
313304
this.textSelection.trigger();
314-
this.filterValue = this.getElementVal(filtered);
315305
return;
316306
}
317307
if (event.key === this.platformUtil.KEYMAP.BACKSPACE
@@ -366,11 +356,6 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
366356
super.onBlur();
367357
}
368358

369-
/** @hidden @internal */
370-
public onFocus(): void {
371-
this._internalFilter = this.comboInput.value || '';
372-
}
373-
374359
/** @hidden @internal */
375360
public getEditElement(): HTMLElement {
376361
return this.comboInput.nativeElement;
@@ -467,7 +452,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
467452
this.selectionService.select_items(this.id, argsSelection, true);
468453
this._value = argsSelection;
469454
if (this._updateInput) {
470-
this.comboInput.value = this._internalFilter = this._displayValue = this.searchValue = displayText !== args.displayText
455+
this.comboInput.value = this._displayValue = this.searchValue = displayText !== args.displayText
471456
? args.displayText
472457
: this.createDisplayText(this.selection, [args.oldSelection]);
473458
}
@@ -547,7 +532,7 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
547532

548533
private clear(): void {
549534
this.clearSelection(true);
550-
this.comboInput.value = this._internalFilter = this._displayValue = this.searchValue = '';
535+
this.comboInput.value = this._displayValue = this.searchValue = '';
551536
}
552537

553538
private isValid(value: any): boolean {

0 commit comments

Comments
 (0)