From 4b933f75ad788c5132130ffbc23bda6ceba82909 Mon Sep 17 00:00:00 2001 From: Jan Grzegorek Date: Sun, 8 Oct 2023 21:10:04 +0200 Subject: [PATCH] issue #4071 fix (#4447) Co-authored-by: jan.g --- components/lib/api/FilterService.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/components/lib/api/FilterService.js b/components/lib/api/FilterService.js index 8185a41f43..4085a50e90 100644 --- a/components/lib/api/FilterService.js +++ b/components/lib/api/FilterService.js @@ -3,11 +3,20 @@ import { ObjectUtils } from 'primevue/utils'; const FilterService = { filter(value, fields, filterValue, filterMatchMode, filterLocale) { let filteredItems = []; + if (!value) { + return filteredItems; + } + + for (const item of value) { + if (typeof item === 'string') { + if (this.filters[filterMatchMode](item, filterValue, filterLocale)) { + filteredItems.push(item); + continue; + } + } else { + for (const field of fields) { + const fieldValue = ObjectUtils.resolveFieldData(item, field); - if (value) { - for (let item of value) { - for (let field of fields) { - let fieldValue = ObjectUtils.resolveFieldData(item, field); if (this.filters[filterMatchMode](fieldValue, filterValue, filterLocale)) { filteredItems.push(item);