MM-17135 ignore at sign when searching for users (#5491)

This commit is contained in:
Elias Nahum 2021-06-29 14:33:04 -04:00 committed by GitHub
parent 4489906698
commit 15a311fcec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -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'];

View file

@ -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) {