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_view_ui: Fix first row being focused after scrolling to bottom.

Aman Agrawal4750f84ba808
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts
index 4aabd71f96b..2d4763d7159 100644
--- a/web/src/recent_view_ui.ts
+++ b/web/src/recent_view_ui.ts
@@ -1177,7 +1177,10 @@ function recenter_focus_if_off_screen(): void {
const topic_center_y = (position.top + position.bottom) / 2;
const topic_element = document.elementFromPoint(topic_center_x, topic_center_y);
- if (topic_element === null) {
+ if (
+ topic_element === null ||
+ $(topic_element).parents("#recent-view-content-tbody").length === 0
+ ) {
// There are two theoretical reasons that the center
// element might be null. One is that we haven't rendered
// the view yet; but in that case, we should have returned