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.

recent_topics: Set focus to first/last row on page up/down at ends.

Aman Agrawalf2f4bed85c72
diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.js
index 6a902425c76..705d237a620 100644
--- a/static/js/recent_topics_ui.js
+++ b/static/js/recent_topics_ui.js
@@ -895,15 +895,24 @@ function get_page_up_down_delta() {
function page_up_navigation() {
const $scroll_container = ui.get_scroll_element($("#recent_topics_table .table_fix_head"));
const delta = get_page_up_down_delta();
-
- $scroll_container.scrollTop($scroll_container.scrollTop() - delta);
+ const new_scrollTop = $scroll_container.scrollTop() - delta;
+ if (new_scrollTop <= 0) {
+ row_focus = 0;
+ }
+ $scroll_container.scrollTop(new_scrollTop);
+ set_table_focus(row_focus, col_focus);
}
function page_down_navigation() {
const $scroll_container = ui.get_scroll_element($("#recent_topics_table .table_fix_head"));
const delta = get_page_up_down_delta();
-
- $scroll_container.scrollTop($scroll_container.scrollTop() + delta);
+ const new_scrollTop = $scroll_container.scrollTop() + delta;
+ const table_height = $("#recent_topics_table .table_fix_head").height();
+ if (new_scrollTop >= table_height) {
+ row_focus = topics_widget.get_current_list().length - 1;
+ }
+ $scroll_container.scrollTop(new_scrollTop);
+ set_table_focus(row_focus, col_focus);
}
function check_row_type_transition(row, col) {