From 986f4499094787b520df095504bd0ae9bb48cb40 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 2 Oct 2015 11:25:41 +0200 Subject: [PATCH] [IMP] mail: client action: focus on composer when opening a channel Disable this feature on mobile as we don't want the mobile composer to open each time we switch from an channel to an other. --- addons/mail/static/src/js/client_action.js | 4 ++++ addons/mail/static/src/js/composer.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 8b847e14df5..7d118ce261f 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -5,6 +5,7 @@ var chat_manager = require('mail.chat_manager'); var ChatComposer = require('mail.ChatComposer'); var ChatThread = require('mail.ChatThread'); +var config = require('web.config'); var ControlPanelMixin = require('web.ControlPanelMixin'); var core = require('web.core'); var data = require('web.data'); @@ -314,6 +315,9 @@ var ChatAction = Widget.extend(ControlPanelMixin, { return this.fetch_and_render_thread().then(function () { self.thread.scroll_to({offset: new_channel_scrolltop}); + if (!config.device.touch) { + self.composer.focus(); + } self.action_manager.do_push_state({ action: self.action.id, active_id: self.channel_id, diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 75244319053..89550789366 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -479,6 +479,9 @@ var Composer = Widget.extend({ is_empty: function () { return !this.$input.val().trim() && !this.$('.o_attachments').children().length; }, + focus: function () { + this.$input.focus(); + }, }); return Composer;