From 0b02ddfc4bf7bb4a42ae510e20d196405d846232 Mon Sep 17 00:00:00 2001 From: Bharat Date: Thu, 1 Apr 2021 13:26:58 +0530 Subject: [PATCH] Returning early in searchFilterCards fn --- webapp/src/viewModel/boardTree.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/webapp/src/viewModel/boardTree.ts b/webapp/src/viewModel/boardTree.ts index b2f279b9f..0ccd86d55 100644 --- a/webapp/src/viewModel/boardTree.ts +++ b/webapp/src/viewModel/boardTree.ts @@ -200,10 +200,18 @@ class MutableBoardTree implements BoardTree { return cards.filter((card: Card) => { const searchTextInCardTitle: boolean = card.title?.toLocaleLowerCase().includes(searchText) - const searchTextInProperties: boolean = Object.values(card.properties). - map((el: string) => el.toLowerCase().includes(searchText)). - some((el: boolean) => el) - return searchTextInCardTitle || searchTextInProperties + if (searchTextInCardTitle) { + return true + } + for (const property in card.properties) { + if ( + Object.prototype.hasOwnProperty.call(card.properties, property) && + card.properties[property].toLowerCase().includes(searchText) + ) { + return true + } + } + return false }) }