mirror of https://github.com/zulip/zulip.git
recent_topics: Return false when escape is unhandled.
When user presses escape but there is no action that recent topics can perform on it, it returns false. The final state of focus is the focus on topics table. If the focus is on table and not on RT search or filters, we return false to indicate that the key was unhandled by recent topics. This will allow escape to take user to another view if recent topics is not the default view.
This commit is contained in:
parent
035299d052
commit
709fbe5c0a
|
@ -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() &&
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue