diff --git a/static/js/hotkey.js b/static/js/hotkey.js index bd866cee9c..dd3d0c24cc 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -214,6 +214,12 @@ export function in_content_editable_widget(e) { // Returns true if we handled it, false if the browser should. export function process_escape_key(e) { + if (hashchange.in_recent_topics_hash() && recent_topics.change_focused_element(e, "escape")) { + // Recent topics uses escape to make focus from RT search / filters to topics table. + // If focus already in table it returns false. + return true; + } + if (in_content_editable_widget(e)) { return false; } @@ -504,7 +510,6 @@ export function process_hotkey(e, hotkey) { case "tab": case "shift_tab": case "open_recent_topics": - case "escape": if ( hashchange.in_recent_topics_hash() && !popovers.any_active() && diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js index 103d08d798..a29c4ca6d9 100644 --- a/static/js/recent_topics.js +++ b/static/js/recent_topics.js @@ -600,6 +600,9 @@ export function change_focused_element(e, input_key) { current_focus_elem = $("#recent_topics_search"); return true; case "escape": + if (current_focus_elem === "table") { + return false; + } set_table_focus(row_focus, col_focus); return true; } @@ -627,12 +630,20 @@ export function change_focused_element(e, input_key) { case "down_arrow": set_table_focus(row_focus, col_focus); return true; + case "escape": + if (current_focus_elem === "table") { + return false; + } + set_table_focus(row_focus, col_focus); + return true; } } else if (current_focus_elem === "table") { // 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). switch (input_key) { + case "escape": + return false; case "open_recent_topics": set_default_focus(); return true; @@ -663,8 +674,9 @@ export function change_focused_element(e, input_key) { set_table_focus(row_focus, col_focus); return true; } - if (current_focus_elem) { + if (current_focus_elem && input_key !== "escape") { current_focus_elem.trigger("focus"); + return true; } return false;