diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 184f1d66e82..744e72742e2 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -458,7 +458,12 @@ var BasicComposer = Widget.extend(chat_mixin, { preprocess_message: function () { // Return a deferred as this function is extended with asynchronous // behavior for the chatter composer - var value = _.escape(this.$input.val()).replace(/\n|\r/g, '
'); + + //Removing unwanted extra spaces from message + var value = _.escape(this.$input.val()).trim(); + value = value.replace(/(\r|\n){2,}/g, '

'); + value = value.replace(/(\r|\n)/g, '
'); + // prevent html space collapsing value = value.replace(/ /g, ' ').replace(/([^>]) ([^<])/g, '$1 $2'); var commands = this.options.commands_enabled ? this.mention_manager.get_listener_selection('/') : [];