From b4d5246545bb13baf6ebf16b28d5fadf5b270aaf Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 26 Oct 2016 11:26:51 +0200 Subject: [PATCH] [IMP] mail: no jump for chatter show older messages When clicking on "Show older messages" in the bottom of the chatter, the page would jump to the top when the additional messages are loaded. There is already a functionality in a discuss channel to stay at the previous scrolling position (related to the content) : https://github.com/odoo/odoo/blob/ffe0db0d/addons/mail/static/src/js/client_action.js#L506-L521 This fix does the same steps for the chatter. opw-692010 --- addons/mail/static/src/js/chatter.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index 5a1f57b3a0f..d2a5cfdb432 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -11,6 +11,7 @@ var core = require('web.core'); var data = require('web.data'); var Dialog = require('web.Dialog'); var form_common = require('web.form_common'); +var framework = require('web.framework'); var session = require('web.session'); var _t = core._t; @@ -841,7 +842,14 @@ var Chatter = form_common.AbstractField.extend({ }, load_more_messages: function () { - this.fetch_and_render_thread(this.msg_ids, {force_fetch: true}); + var self = this; + var top_msg_id = this.$('.o_thread_message').first().data('messageId'); + var top_msg_selector = '.o_thread_message[data-message-id="' + top_msg_id + '"]'; + var offset = -framework.getPosition(document.querySelector(top_msg_selector)).top; + this.fetch_and_render_thread(this.msg_ids, {force_fetch: true}).then(function(){ + offset += framework.getPosition(document.querySelector(top_msg_selector)).top; + self.thread.scroll_to({offset: offset}); + }); }, /**