From 5ee78fc14c0e12d6302a4d0d48f3e385a2cdf6b9 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Sun, 23 Oct 2022 06:41:07 +0000 Subject: [PATCH] recent_topics: Don't process hotkeys in empty table. The fixes errors when we are trying process user input before anything is initialized in recent topics. --- static/js/recent_topics_ui.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.js index 9548ef9597..3683b87503 100644 --- a/static/js/recent_topics_ui.js +++ b/static/js/recent_topics_ui.js @@ -1038,6 +1038,11 @@ export function change_focused_element($elt, input_key) { return true; } } else if (is_table_focused()) { + // Don't process hotkeys in table if there are no rows. + if (!topics_widget || topics_widget.get_current_list().length === 0) { + return true; + } + // For arrowing around the table of topics, we implement left/right // wraparound. Going off the top or the bottom takes one // to the navigation at the top (see set_table_focus).