Fix: only filter by string or number properties for filter pipe (#7699)

This commit is contained in:
shamoon 2024-09-13 20:41:31 -07:00 committed by GitHub
parent 66a8057e31
commit 8e555cce9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,11 +10,16 @@ export class FilterPipe implements PipeTransform {
if (!searchText) return items
return items.filter((item) => {
return Object.keys(item).some((key) => {
return String(item[key])
.toLowerCase()
.includes(searchText.toLowerCase())
})
return Object.keys(item)
.filter(
(key) =>
typeof item[key] === 'string' || typeof item[key] === 'number'
)
.some((key) => {
return String(item[key])
.toLowerCase()
.includes(searchText.toLowerCase())
})
})
}
}