mirror of https://github.com/zulip/zulip.git
recent_topics: Directly pass jquery element instead of event object.
This commit is contained in:
parent
493c00f2ad
commit
f79a59d5f8
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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":
|
||||
|
|
Loading…
Reference in New Issue