Skip to content

Commit

Permalink
14194: Fixed filter with default 'label' field
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnyab28 committed Nov 28, 2023
1 parent a28b9fc commit d6c3eae
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
}

searchFields() {
return this.filterFields || [this.optionLabel];
return (this.filterBy || this.optionLabel || 'label').split(',');
}

findNearestSelectedOptionIndex(index, firstCheckUp = false) {
Expand Down Expand Up @@ -2052,20 +2052,18 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft

activateFilter() {
if (this.hasFilter() && this._options) {
let searchFields: string[] = (this.filterBy || this.optionLabel || 'label').split(',');

if (this.group) {
let filteredGroups = [];
for (let optgroup of this.options as any[]) {
let filteredSubOptions = this.filterService.filter(this.getOptionGroupChildren(optgroup), searchFields, this.filterValue, this.filterMatchMode, this.filterLocale);
let filteredSubOptions = this.filterService.filter(this.getOptionGroupChildren(optgroup), this.searchFields(), this.filterValue, this.filterMatchMode, this.filterLocale);
if (filteredSubOptions && filteredSubOptions.length) {
filteredGroups.push({ ...optgroup, ...{ [this.optionGroupChildren]: filteredSubOptions } });
}
}

this._filteredOptions = filteredGroups;
} else {
this._filteredOptions = this.filterService.filter(this.options as any[], searchFields, this._filterValue, this.filterMatchMode, this.filterLocale);
this._filteredOptions = this.filterService.filter(this.options as any[], this.searchFields(), this.filterValue, this.filterMatchMode, this.filterLocale);
}
} else {
this._filteredOptions = null;
Expand Down

0 comments on commit d6c3eae

Please sign in to comment.