From a7d0e215756ef4bd7d6b253560d952fddf7e17c9 Mon Sep 17 00:00:00 2001 From: acran Date: Tue, 14 Mar 2017 17:18:02 +0100 Subject: [PATCH] allow editting mentions text for users with usernames (#1347) when now holding the Alt key while selecting a user from the mentions autocomplete suggestions the text inserted into the composer will be forced to be in the @1234567 (firstname) format (i.e. referring to the user by id and local firstname) instead of @username even if the selected user has a username set. This allows to manually edit the display text ("firstname") of the mention. --- app/js/message_composer.js | 14 ++++++++++++-- app/partials/desktop/composer_dropdown.html | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/js/message_composer.js b/app/js/message_composer.js index eb28cab5..b67c35f7 100644 --- a/app/js/message_composer.js +++ b/app/js/message_composer.js @@ -785,7 +785,12 @@ MessageComposer.prototype.setUpAutoComplete = function () { } EmojiHelper.pushPopularEmoji(code) } - if (mention = target.attr('data-mention')) { + if (e.altKey || !target.attr('data-username')) { + mention = target.attr('data-user-id') + } else { + mention = target.attr('data-username') + } + if (mention) { self.onMentionSelected(mention, target.attr('data-name')) } if (command = target.attr('data-command')) { @@ -911,7 +916,12 @@ MessageComposer.prototype.onKeyEvent = function (e) { EmojiHelper.pushPopularEmoji(code) return cancelEvent(e) } - if (mention = currentSel.attr('data-mention')) { + if (e.altKey || !currentSel.attr('data-username')) { + mention = currentSel.attr('data-user-id') + } else { + mention = currentSel.attr('data-username') + } + if (mention) { this.onMentionSelected(mention, currentSel.attr('data-name')) return cancelEvent(e) } diff --git a/app/partials/desktop/composer_dropdown.html b/app/partials/desktop/composer_dropdown.html index e50c05a4..0ca101b2 100644 --- a/app/partials/desktop/composer_dropdown.html +++ b/app/partials/desktop/composer_dropdown.html @@ -2,7 +2,7 @@