From 7e365fa56caa4d7a6969f17e2a1803bcd7da432d Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Thu, 12 Sep 2024 14:17:30 +0200 Subject: [PATCH 1/2] fix flicker --- .../SearchFiltersParticipantsSelector.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/Search/SearchFiltersParticipantsSelector.tsx b/src/components/Search/SearchFiltersParticipantsSelector.tsx index 436cdba91af2..8ac00dc9d494 100644 --- a/src/components/Search/SearchFiltersParticipantsSelector.tsx +++ b/src/components/Search/SearchFiltersParticipantsSelector.tsx @@ -104,19 +104,20 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}: true, ); - const isCurrentUserSelected = selectedOptions.find((option) => option.accountID === chatOptions.currentUserOption?.accountID); + const currentUser = formattedResults.section.data.find((option) => option.accountID === chatOptions.currentUserOption?.accountID); - newSections.push(formattedResults.section); - - if (chatOptions.currentUserOption && !isCurrentUserSelected) { + if (chatOptions.currentUserOption) { const formattedName = ReportUtils.getDisplayNameForParticipant(chatOptions.currentUserOption.accountID, false, true, true, personalDetails); - newSections.push({ - title: '', - data: [{...chatOptions.currentUserOption, text: formattedName}], - shouldShow: true, - }); + if (!currentUser) { + chatOptions.currentUserOption.text = formattedName; + chatOptions.recentReports.unshift(chatOptions.currentUserOption); + } else { + currentUser.text = formattedName; + } } + newSections.push(formattedResults.section); + newSections.push({ title: '', data: chatOptions.recentReports, From 4bc631e2165106a565645a48ef6165eb687cbc54 Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Thu, 12 Sep 2024 16:41:11 +0200 Subject: [PATCH 2/2] review --- .../Search/SearchFiltersParticipantsSelector.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Search/SearchFiltersParticipantsSelector.tsx b/src/components/Search/SearchFiltersParticipantsSelector.tsx index 8ac00dc9d494..a76ca767ae2a 100644 --- a/src/components/Search/SearchFiltersParticipantsSelector.tsx +++ b/src/components/Search/SearchFiltersParticipantsSelector.tsx @@ -104,15 +104,15 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}: true, ); - const currentUser = formattedResults.section.data.find((option) => option.accountID === chatOptions.currentUserOption?.accountID); + const selectedCurrentUser = formattedResults.section.data.find((option) => option.accountID === chatOptions.currentUserOption?.accountID); if (chatOptions.currentUserOption) { const formattedName = ReportUtils.getDisplayNameForParticipant(chatOptions.currentUserOption.accountID, false, true, true, personalDetails); - if (!currentUser) { - chatOptions.currentUserOption.text = formattedName; - chatOptions.recentReports.unshift(chatOptions.currentUserOption); + if (selectedCurrentUser) { + selectedCurrentUser.text = formattedName; } else { - currentUser.text = formattedName; + chatOptions.currentUserOption.text = formattedName; + chatOptions.recentReports = [chatOptions.currentUserOption, ...chatOptions.recentReports]; } } @@ -137,7 +137,7 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}: sections: newSections, headerMessage: message, }; - }, [areOptionsInitialized, cleanSearchTerm, selectedOptions, chatOptions.recentReports, chatOptions.personalDetails, chatOptions.currentUserOption, personalDetails, translate]); + }, [areOptionsInitialized, cleanSearchTerm, selectedOptions, chatOptions, personalDetails, translate]); // This effect handles setting initial selectedOptions based on accountIDs saved in onyx form useEffect(() => {