diff --git a/web/src/recent_view_ui.js b/web/src/recent_view_ui.js index 01095dc5f0..10fb7d9142 100644 --- a/web/src/recent_view_ui.js +++ b/web/src/recent_view_ui.js @@ -96,6 +96,12 @@ let dropdown_filters = new Set(); const recent_conversation_key_prefix = "recent_conversation:"; +let is_initial_message_fetch_pending = true; + +export function set_initial_message_fetch_status(value) { + is_initial_message_fetch_pending = value; +} + export function clear_for_tests() { filters.clear(); dropdown_filters.clear(); @@ -341,6 +347,12 @@ export function revive_current_focus() { // to the focused element, this function attempts to revive the // link and focus to the element prior to the rerender. + // We want to set focus on table by default, but we have to wait for + // initial fetch for rows to appear otherwise focus is set to search input. + if (is_initial_message_fetch_pending) { + return false; + } + // We try to avoid setting focus when user // is not focused on Recent Conversations. if (!is_in_focus()) { diff --git a/web/src/ui_init.js b/web/src/ui_init.js index fb6ea0bb6c..391cfa9347 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -799,7 +799,11 @@ export function initialize_everything(state_data) { reload_setup.initialize(); unread.initialize(unread_params); bot_data.initialize(bot_params); // Must happen after people.initialize() - message_fetch.initialize(server_events.finished_initial_fetch); + message_fetch.initialize(() => { + recent_view_ui.set_initial_message_fetch_status(false); + recent_view_ui.revive_current_focus(); + server_events.finished_initial_fetch(); + }); message_scroll.initialize(); markdown.initialize(markdown_config.get_helpers()); linkifiers.initialize(realm.realm_linkifiers);