From 15a311fcecae5800e5ea0b5fcbd883a5cfd19867 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 29 Jun 2021 14:33:04 -0400 Subject: [PATCH] MM-17135 ignore at sign when searching for users (#5491) --- .../main/channels_list/filtered_list/filtered_list.js | 6 +++++- app/selectors/autocomplete.js | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js b/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js index b884f4bf7..244c040d5 100644 --- a/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js +++ b/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js @@ -120,7 +120,11 @@ class FilteredList extends Component { return channels; } - const text = term.toLowerCase(); + let text = term.toLowerCase(); + if (text.startsWith('@')) { + text = text.substring(1); + } + return channels.filter((c) => { const fieldsToCheck = ['display_name', 'username', 'email', 'full_name', 'nickname']; diff --git a/app/selectors/autocomplete.js b/app/selectors/autocomplete.js index 5e9c896a1..559cd452d 100644 --- a/app/selectors/autocomplete.js +++ b/app/selectors/autocomplete.js @@ -23,7 +23,12 @@ export const getMatchTermForAtMention = (() => { return (value, isSearch) => { if (value !== lastValue || isSearch !== lastIsSearch) { const regex = isSearch ? Autocomplete.AT_MENTION_SEARCH_REGEX : Autocomplete.AT_MENTION_REGEX; - const match = value.match(regex); + let term = value; + if (term.startsWith('from: @') || term.startsWith('from:@')) { + term = term.replace('@', ''); + } + + const match = term.match(regex); lastValue = value; lastIsSearch = isSearch; if (match) {