diff --git a/webapp/components/suggestion/at_mention_provider.jsx b/webapp/components/suggestion/at_mention_provider.jsx index aec1252eaf..e650ad3e7d 100644 --- a/webapp/components/suggestion/at_mention_provider.jsx +++ b/webapp/components/suggestion/at_mention_provider.jsx @@ -16,12 +16,13 @@ const MaxUserSuggestions = 40; class AtMentionSuggestion extends Suggestion { render() { - const {item, isSelection} = this.props; + const isSelection = this.props.isSelection; + const user = this.props.item; let username; let description; let icon; - if (item.username === 'all') { + if (user.username === 'all') { username = 'all'; description = ( ); icon = ; - } else if (item.username === 'channel') { + } else if (user.username === 'channel') { username = 'channel'; description = ( ; } else { - username = item.username; - description = Utils.getFullName(item); + username = user.username; + + if ((user.first_name || user.last_name) && user.nickname) { + description = ` - ${Utils.getFullName(user)} (${user.nickname})`; + } else if (user.nickname) { + description = ` - (${user.nickname})`; + } else if (user.first_name || user.last_name) { + description = ` - ${Utils.getFullName(user)}`; + } + icon = ( a.username.localeCompare(b.username)); + filtered.sort((a, b) => { + const aPrefix = a.username.startsWith(prefix); + const bPrefix = b.username.startsWith(prefix); + + if (aPrefix === bPrefix) { + return a.username.localeCompare(b.username); + } else if (aPrefix) { + return -1; + } + + return 1; + }); const mentions = filtered.map((user) => '@' + user.username); diff --git a/webapp/sass/components/_mentions.scss b/webapp/sass/components/_mentions.scss index 82f626eafe..17f67d0806 100644 --- a/webapp/sass/components/_mentions.scss +++ b/webapp/sass/components/_mentions.scss @@ -50,7 +50,6 @@ .mention__fullname { @include opacity(.5); - padding-left: 10px; } .mention--highlight {