From 2c48bec19c6573eae5a6bb821c3605c3273d36d6 Mon Sep 17 00:00:00 2001 From: mpiccinnonode Date: Wed, 15 Jan 2025 14:19:54 +0100 Subject: [PATCH 1/2] Update multiselect.ts --- packages/primeng/src/multiselect/multiselect.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/primeng/src/multiselect/multiselect.ts b/packages/primeng/src/multiselect/multiselect.ts index 2adef57a9f..4849d12e4a 100755 --- a/packages/primeng/src/multiselect/multiselect.ts +++ b/packages/primeng/src/multiselect/multiselect.ts @@ -1261,14 +1261,16 @@ export class MultiSelect extends BaseComponent implements OnInit, AfterViewInit, visibleOptions = computed(() => { const options = this.getAllVisibleAndNonVisibleOptions(); - const isArrayOfObjects = isArray(options) && isObject(options[0]); + const isArrayOfObjects = isArray(options) && this._isObject(options[0]); if (this._filterValue()) { let filteredOptions; if (isArrayOfObjects) { + console.log('into obj filtering'); filteredOptions = this.filterService.filter(options, this.searchFields(), this._filterValue(), this.filterMatchMode, this.filterLocale); } else { + console.log('into string filtering'); filteredOptions = options.filter((option) => option.toString().toLocaleLowerCase().includes(this._filterValue().toLocaleLowerCase())); } @@ -2306,6 +2308,10 @@ export class MultiSelect extends BaseComponent implements OnInit, AfterViewInit, hasFilter() { return this._filterValue() && this._filterValue().trim().length > 0; } + + private _isObject(value, empty = true) { + return typeof value === 'object' && !Array.isArray(value) && value != null && (empty || Object.keys(value).length !== 0); + } } @NgModule({ From 9261d80e0c5e33f97022655ecd660cd4e06764ed Mon Sep 17 00:00:00 2001 From: mpiccinnonode Date: Thu, 16 Jan 2025 10:31:08 +0100 Subject: [PATCH 2/2] Update multiselect.ts --- packages/primeng/src/multiselect/multiselect.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/primeng/src/multiselect/multiselect.ts b/packages/primeng/src/multiselect/multiselect.ts index 4849d12e4a..5d35de9e8a 100755 --- a/packages/primeng/src/multiselect/multiselect.ts +++ b/packages/primeng/src/multiselect/multiselect.ts @@ -1267,10 +1267,8 @@ export class MultiSelect extends BaseComponent implements OnInit, AfterViewInit, let filteredOptions; if (isArrayOfObjects) { - console.log('into obj filtering'); filteredOptions = this.filterService.filter(options, this.searchFields(), this._filterValue(), this.filterMatchMode, this.filterLocale); } else { - console.log('into string filtering'); filteredOptions = options.filter((option) => option.toString().toLocaleLowerCase().includes(this._filterValue().toLocaleLowerCase())); }