From ede4271394f2a702d6a18151b3f0fad44a0a6d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Mon, 12 Feb 2024 11:47:08 +0300 Subject: [PATCH 1/2] add new methods --- src/app/components/utils/objectutils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) 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); From ed2c8679ed7dfc37784a1e12f1ab0d320a818528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Mon, 12 Feb 2024 11:55:08 +0300 Subject: [PATCH 2/2] Fixed #12854 - Multiselect | Multiselect with string array search not working --- src/app/components/multiselect/multiselect.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 = [];