From ca0f79ce34d31f366c5de90cfdde80a08fee0d2a Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Thu, 18 Apr 2024 11:13:07 +0000 Subject: [PATCH] message_list_view: Restore date on previous sticky header. We forgot to restore the date on sticky header if the header is no longer sticky. Reproducer: * Have two messages with same sender on different dates next to each other in a stream narrow. * Scroll so that sticky header is on the 2nd message. * Scroll down fast so that to avoid us capturing the sticky header over the first message. * Scroll up slowly so to see the group header of the messages have the date of the second message. --- web/src/message_list_view.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index 1e829e3eda..b2b5703c75 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -1594,8 +1594,22 @@ export class MessageListView { /* No headers are present */ return; } - /* Intentionally remove sticky headers class here to make calculations simpler. */ - $(".sticky_header").removeClass("sticky_header"); + + const $current_sticky_header = $(".sticky_header"); + if ($current_sticky_header.length === 1) { + // Reset the date on the header in case we changed it. + const message_group_id = rows + .get_message_recipient_row($current_sticky_header) + .attr("id"); + const group = this._find_message_group(message_group_id); + if (group !== undefined) { + const rendered_date = group.date; + $current_sticky_header.find(".recipient_row_date").html(rendered_date); + /* Intentionally remove sticky headers class here to make calculations simpler. */ + } + $current_sticky_header.removeClass("sticky_header"); + } + /* visible_top is navbar top position + height for us. */ const visible_top = message_viewport.message_viewport_info().visible_top; /* We need date to be properly visible on the header, so partially visible headers