From 561902b18058173a96a34d963636002089ded014 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Wed, 28 Jun 2023 14:44:30 +0200 Subject: [PATCH] message-list-view: Update sticky header in rerender_messages. When a message list view rerenders a locally echoed message the message recipient header is also rerendered, which then removes the "sticky_header" class if it was present. If rerendering the message triggers a non-user initiated scroll event, then the "sticky_header" class is updated. But it is possible that the rerendering of the message will not trigger a scroll event, which means the recipient header is no longer updated and the next calculation for the message list view's _scroll_limit for the top of the feed will not include the sticky header and the currently selected message may be scrolled partially or completely under the message header recipient bar. In message_list_view.rerender_messages, adds a check, after calling _rerender_header in a loop, for the current message list and calls update_sticky_recipient_headers if the message feed is visible. Adds a comment to _rerender_header that we expect it to only be called in rerender_messages so that the "sticky_header" class is updated if needed. --- web/src/message_list_view.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index d92f2e9f8e..15b5962426 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -1208,7 +1208,9 @@ export class MessageListView { _rerender_header(message_containers) { // Given a list of messages that are in the **same** message group, - // rerender the header / recipient bar of the messages + // rerender the header / recipient bar of the messages. This method + // should only be called with rerender_messages as the rerendered + // header may need to be updated for the "sticky_header" class. if (message_containers.length === 0) { return; } @@ -1315,6 +1317,10 @@ export class MessageListView { for (const messages_in_group of message_groups) { this._rerender_header(messages_in_group, message_content_edited); } + + if (message_lists.current === this.list && narrow_state.is_message_feed_visible()) { + this.update_sticky_recipient_headers(); + } } append(messages, messages_are_new) {