From ea2307fea7b21d411d70afb376391ea228b1955d Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 13 Sep 2023 15:32:46 +0200 Subject: [PATCH 1/2] improve selected condition of option row --- src/components/OptionsList/BaseOptionsList.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/OptionsList/BaseOptionsList.js b/src/components/OptionsList/BaseOptionsList.js index 252b015edd45..1e936df11f98 100644 --- a/src/components/OptionsList/BaseOptionsList.js +++ b/src/components/OptionsList/BaseOptionsList.js @@ -170,6 +170,20 @@ function BaseOptionsList({ */ const renderItem = ({item, index, section}) => { const isItemDisabled = isDisabled || section.isDisabled || !!item.isDisabled; + const isSelected = Boolean( + _.find(selectedOptions, (option) => { + if (option.accountID === item.accountID) { + return true; + } + + if (_.isEmpty(option.name)) { + return false; + } + + return option.name === item.searchText; + }), + ); + return ( option.accountID === item.accountID || option.name === item.searchText))} + isSelected={isSelected} showSelectedState={canSelectMultipleOptions} highlightSelected={highlightSelectedOptions} boldStyle={boldStyle} From 68727ae16cb95276ce1781b9ca46a1116a60caef Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 13 Sep 2023 16:55:53 +0200 Subject: [PATCH 2/2] simplify --- src/components/OptionsList/BaseOptionsList.js | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.js b/src/components/OptionsList/BaseOptionsList.js index 1e936df11f98..47efa1a5ac9e 100644 --- a/src/components/OptionsList/BaseOptionsList.js +++ b/src/components/OptionsList/BaseOptionsList.js @@ -170,19 +170,17 @@ function BaseOptionsList({ */ const renderItem = ({item, index, section}) => { const isItemDisabled = isDisabled || section.isDisabled || !!item.isDisabled; - const isSelected = Boolean( - _.find(selectedOptions, (option) => { - if (option.accountID === item.accountID) { - return true; - } + const isSelected = _.some(selectedOptions, (option) => { + if (option.accountID === item.accountID) { + return true; + } - if (_.isEmpty(option.name)) { - return false; - } + if (_.isEmpty(option.name)) { + return false; + } - return option.name === item.searchText; - }), - ); + return option.name === item.searchText; + }); return (