Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14194: Fixed filter with default 'label' field #14220

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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