From 2f58e95a8d0c8586ac3ef00e560f71c31b238778 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 15 Feb 2016 09:58:12 +0100 Subject: [PATCH] [FIX] mail: composer: correctly erase mentions The problem was that mentions weren't correctly erased with DELETE key (in some conditions), or when replacing mention text. When this happened, the mention didn't appear in the message, but the message was even tough sent to the erased mentioned people. With this rev., we don't try to detect erasing on the fly anymore, but we rather validate mentions before sending the message with the content of the input. opw 669362 --- addons/mail/static/src/js/composer.js | 58 +++++++++++---------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 6ffd2bc63c3..4fafe8427eb 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -27,6 +27,8 @@ var accented_letters_mapping = { ' ': '[()\\[\\]]', }; +var NON_BREAKING_SPACE = '\u00a0'; + var MENTION_PARTNER_DELIMITER = '@'; var MENTION_CHANNEL_DELIMITER = '#'; @@ -71,6 +73,8 @@ var MentionManager = Widget.extend({ var selected_suggestion = _.find(_.flatten(this.get('mention_suggestions')), function (s) { return s.id === id; }); + // replace white spaces with non-breaking spaces to facilitate mentions detection in text + selected_suggestion.name = selected_suggestion.name.replace(/ /g, NON_BREAKING_SPACE); var get_mention_index = function (matches, cursor_position) { for (var i=0; i