Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

navigate: Fix down arrow on last long msg not working as expected.

Aman Agrawal48261c0b65a8
diff --git a/web/src/navigate.ts b/web/src/navigate.ts
index 4fad25174b8..1ed3b613f21 100644
--- a/web/src/navigate.ts
+++ b/web/src/navigate.ts
@@ -62,20 +62,6 @@ export function down(with_centering = false): void {
assert(message_lists.current !== undefined);
message_viewport.set_last_movement_direction(1);
- if (message_lists.current.is_at_end()) {
- if (with_centering) {
- // At the last message, scroll to the bottom so we have
- // lots of nice whitespace for new messages coming in.
- const $current_msg_list = message_lists.current.view.$list;
- message_viewport.scrollTop(
- ($current_msg_list.outerHeight(true) ?? 0) - message_viewport.height() * 0.1,
- );
- unread_ops.process_visible();
- }
-
- return;
- }
-
const $selected_message = message_lists.current.selected_row();
if ($selected_message.length > 0) {
const viewport_info = message_viewport.message_viewport_info();
@@ -90,6 +76,20 @@ export function down(with_centering = false): void {
}
}
+ if (message_lists.current.is_at_end()) {
+ if (with_centering) {
+ // At the last message, scroll to the bottom so we have
+ // lots of nice whitespace for new messages coming in.
+ const $current_msg_list = message_lists.current.view.$list;
+ message_viewport.scrollTop(
+ ($current_msg_list.outerHeight(true) ?? 0) - message_viewport.height() * 0.1,
+ );
+ unread_ops.process_visible();
+ }
+
+ return;
+ }
+
// Normal path starts here.
const msg_id = message_lists.current.next();
if (msg_id === undefined) {