Skip to content

Commit

Permalink
Merge pull request #49072 from software-mansion-labs/289Adam289/48946…
Browse files Browse the repository at this point in the history
…-fix-participantsSelector-flicker

fix flicker on from and to advanced filters
  • Loading branch information
luacmartins authored Sep 17, 2024
2 parents 2702e38 + 4bc631e commit eb79a24
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/components/Search/SearchFiltersParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,20 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate}:
true,
);

const isCurrentUserSelected = selectedOptions.find((option) => option.accountID === chatOptions.currentUserOption?.accountID);
const selectedCurrentUser = 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 (selectedCurrentUser) {
selectedCurrentUser.text = formattedName;
} else {
chatOptions.currentUserOption.text = formattedName;
chatOptions.recentReports = [chatOptions.currentUserOption, ...chatOptions.recentReports];
}
}

newSections.push(formattedResults.section);

newSections.push({
title: '',
data: chatOptions.recentReports,
Expand All @@ -136,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(() => {
Expand Down

0 comments on commit eb79a24

Please sign in to comment.