From dfda1d3137a63004e09b3d9d58288cc12dee187a Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Wed, 24 Jul 2013 10:39:27 -0400 Subject: [PATCH] Fix collapse issue introduced by ca50035 while keeping the effect of its fix. That commit intended to fix a bug where it jumps to the wrong scroll position (offset by the difference in height from uncollapsed to collapsed) if you load collapsed messages at the top, either by scrolling up or when it automatically fetches more 10s after page load, because before, it updated the scroll position before processing collapsing, which changes the height of messages. Updating collapsing needs to happen before the viewport is adjusted, but also needs to happen after the new messages get appended/prepended to the document because they need to be attached to the document for getClientBoundingRect to work. (imported from commit 44d6a6135524e658084ffcf7d880ba898b577e6d) --- zephyr/static/js/message_list.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zephyr/static/js/message_list.js b/zephyr/static/js/message_list.js index 0b8963a6e7..2163e693ee 100644 --- a/zephyr/static/js/message_list.js +++ b/zephyr/static/js/message_list.js @@ -434,19 +434,10 @@ MessageList.prototype = { } } - $.each(rendered_elems, ui.process_condensing); - if (where === 'top' && table.find('.ztable_layout_row').length > 0) { // If we have a totally empty narrow, there may not // be a .ztable_layout_row. table.find('.ztable_layout_row').after(rendered_elems); - - if (this === current_msg_list && orig_scrolltop_offset !== undefined) { - // Restore the selected row to its original position in - // relation to the top of the window - viewport.scrollTop(this.selected_row().offset().top - orig_scrolltop_offset); - this.select_id(this._selected_id, {from_rendering: true}); - } } else { table.append(rendered_elems); @@ -477,6 +468,15 @@ MessageList.prototype = { message_edit.maybe_show_edit(row, id); }); + $.each(rendered_elems, ui.process_condensing); + + if (where === 'top' && this === current_msg_list && orig_scrolltop_offset !== undefined) { + // Restore the selected row to its original position in + // relation to the top of the window + viewport.scrollTop(this.selected_row().offset().top - orig_scrolltop_offset); + this.select_id(this._selected_id, {from_rendering: true}); + } + // Re-add the fading of messages that is lost when we re-render. compose.update_faded_messages();