diff --git a/src/app/components/multiselect/multiselect.ts b/src/app/components/multiselect/multiselect.ts index e51a28054d1..04105dd098d 100755 --- a/src/app/components/multiselect/multiselect.ts +++ b/src/app/components/multiselect/multiselect.ts @@ -1038,11 +1038,20 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft return this.config.translation.aria ? this.config.translation.aria.close : undefined; } + visibleOptions = computed(() => { const options = this.group ? this.flatOptions(this.options) : this.options || []; - + const isArrayOfObjects = ObjectUtils.isArray(options) && ObjectUtils.isObject(options[0]) + if (this._filterValue()) { - const filteredOptions = this.filterService.filter(options, this.searchFields(), this._filterValue(), this.filterMatchMode, this.filterLocale); + let filteredOptions; + + if (isArrayOfObjects) { + filteredOptions = this.filterService.filter(options, this.searchFields(), this._filterValue(), this.filterMatchMode, this.filterLocale); + } else { + filteredOptions = options.filter((option) => option.toLocaleLowerCase().includes(this._filterValue().toLocaleLowerCase())); + } + if (this.group) { const optionGroups = this.options || []; const filtered = []; diff --git a/src/app/components/utils/objectutils.ts b/src/app/components/utils/objectutils.ts index 95d169637d6..d55d17eabd5 100644 --- a/src/app/components/utils/objectutils.ts +++ b/src/app/components/utils/objectutils.ts @@ -1,4 +1,12 @@ export class ObjectUtils { + public static isArray(value, empty = true) { + return Array.isArray(value) && (empty || value.length !== 0); + } + + public static isObject(value, empty = true) { + return value instanceof Object && value.constructor === Object && (empty || Object.keys(value).length !== 0); + } + public static equals(obj1: any, obj2: any, field?: string): boolean { if (field) return this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field); else return this.equalsByValue(obj1, obj2);