From 4750f84ba808a3151733866dbc0dc339754979ef Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Tue, 4 Jun 2024 08:37:57 +0000 Subject: [PATCH] recent_view_ui: Fix first row being focused after scrolling to bottom. If recent view load more banner is at the center as a result of `document.elementFromPoint(topic_center_x, topic_center_y)`, there is no `tr` to focus, resulting in first row to be focused as the closest element as per previous logic. To fix it, we just focus the last row which is just above the load more banner and is visible. --- web/src/recent_view_ui.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts index 4aabd71f96..2d4763d715 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