Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

recent_topics: Directly pass jquery element instead of event object.

Aman Agrawalf79a59d5f827
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 8c630d2a27d..5e6b88e5d5f 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -450,7 +450,7 @@ export function initialize() {
$("body").on("click", "#recent_topics_search", (e) => {
e.stopPropagation();
- recent_topics.change_focused_element(e, "click");
+ recent_topics.change_focused_element($(e.target), "click");
});
$("body").on("click", "#recent_topics_table .on_hover_topic_read", (e) => {
@@ -465,7 +465,7 @@ export function initialize() {
$("body").on("click", ".btn-recent-filters", (e) => {
e.stopPropagation();
- recent_topics.change_focused_element(e, "click");
+ recent_topics.change_focused_element($(e.target), "click");
recent_topics.set_filter(e.currentTarget.dataset.filter);
recent_topics.update_filters_view();
});
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index 7621e7c129d..9e54b0ae7da 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -216,7 +216,10 @@ 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")) {
+ if (
+ hashchange.in_recent_topics_hash() &&
+ recent_topics.change_focused_element($(e.target), "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;
@@ -532,7 +535,7 @@ export function process_hotkey(e, hotkey) {
!$(".user-list-filter").is(":focus") &&
!$(".stream-list-filter").is(":focus")
) {
- return recent_topics.change_focused_element(e, event_name);
+ return recent_topics.change_focused_element($(e.target), event_name);
}
}
diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js
index 82fa543e7b6..39ab019048a 100644
--- a/static/js/recent_topics.js
+++ b/static/js/recent_topics.js
@@ -565,14 +565,13 @@ export function focus_clicked_element($elt, col) {
row_focus = $elt.closest("tr").index();
}
-export function change_focused_element(e, input_key) {
+export function change_focused_element($elt, input_key) {
// Called from hotkeys.js; like all logic in that module,
// returning true will cause the caller to do
// preventDefault/stopPropagation; false will let the browser
// handle the key.
- const $elem = $(e.target);
- if (e.target.id === "recent_topics_search") {
+ if ($elt.attr("id") === "recent_topics_search") {
// Since the search box a text area, we want the browser to handle
// Left/Right and selection within the widget; but if the user
// arrows off the edges, we should move focus to the adjacent widgets..
@@ -631,27 +630,27 @@ export function change_focused_element(e, input_key) {
set_table_focus(row_focus, col_focus);
return true;
}
- } else if ($elem.hasClass("btn-recent-filters")) {
+ } else if ($elt.hasClass("btn-recent-filters")) {
switch (input_key) {
case "click":
- current_focus_elem = $elem;
+ current_focus_elem = $elt;
return true;
case "shift_tab":
case "vim_left":
case "left_arrow":
- if (filter_buttons().first()[0] === $elem[0]) {
+ if (filter_buttons().first()[0] === $elt[0]) {
current_focus_elem = $("#recent_topics_search");
} else {
- current_focus_elem = $elem.prev();
+ current_focus_elem = $elt.prev();
}
break;
case "tab":
case "vim_right":
case "right_arrow":
- if (filter_buttons().last()[0] === $elem[0]) {
+ if (filter_buttons().last()[0] === $elt[0]) {
current_focus_elem = $("#recent_topics_search");
} else {
- current_focus_elem = $elem.next();
+ current_focus_elem = $elt.next();
}
break;
case "vim_down":