Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_topics: Directly pass topic index instead of element.
Aman Agrawal7f61997d095b
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.jsindex 2da02bc9850..94ac78fbd09 100644--- a/static/js/click_handlers.js+++ b/static/js/click_handlers.js@@ -385,7 +385,8 @@ export function initialize() {$("body").on("click", "#recent_topics_table .on_hover_topic_unmute", (e) => {e.stopPropagation();const $elt = $(e.target);- recent_topics_ui.focus_clicked_element($elt, recent_topics_ui.COLUMNS.mute);+ const topic_row_index = $elt.closest("tr").index();+ recent_topics_ui.focus_clicked_element(topic_row_index, recent_topics_ui.COLUMNS.mute);mute_or_unmute_topic($elt, false);});@@ -394,7 +395,8 @@ export function initialize() {$("body").on("click", "#recent_topics_table .on_hover_topic_mute", (e) => {e.stopPropagation();const $elt = $(e.target);- recent_topics_ui.focus_clicked_element($elt, recent_topics_ui.COLUMNS.mute);+ const topic_row_index = $elt.closest("tr").index();+ recent_topics_ui.focus_clicked_element(topic_row_index, recent_topics_ui.COLUMNS.mute);mute_or_unmute_topic($elt, true);});@@ -405,7 +407,8 @@ export function initialize() {$("body").on("click", "#recent_topics_table .on_hover_topic_read", (e) => {e.stopPropagation();- recent_topics_ui.focus_clicked_element($(e.target), recent_topics_ui.COLUMNS.read);+ const topic_row_index = $(e.target).closest("tr").index();+ recent_topics_ui.focus_clicked_element(topic_row_index, recent_topics_ui.COLUMNS.read);const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id"), 10);const topic = $(e.currentTarget).attr("data-topic-name");unread_ops.mark_topic_as_read(stream_id, topic);@@ -423,13 +426,16 @@ export function initialize() {$("body").on("click", "td.recent_topic_stream", (e) => {e.stopPropagation();- recent_topics_ui.focus_clicked_element($(e.target), recent_topics_ui.COLUMNS.stream);+ const topic_row_index = $(e.target).closest("tr").index();+ recent_topics_ui.focus_clicked_element(topic_row_index, recent_topics_ui.COLUMNS.stream);window.location.href = $(e.currentTarget).find("a").attr("href");});$("body").on("click", "td.recent_topic_name", (e) => {e.stopPropagation();- recent_topics_ui.focus_clicked_element($(e.target), recent_topics_ui.COLUMNS.topic);+ const topic_row = $(e.target).closest("tr");+ const topic_row_index = topic_row.index();+ recent_topics_ui.focus_clicked_element(topic_row_index, recent_topics_ui.COLUMNS.topic);window.location.href = $(e.currentTarget).find("a").attr("href");});diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.jsindex e140ed94968..0ff19bd5e92 100644--- a/static/js/recent_topics_ui.js+++ b/static/js/recent_topics_ui.js@@ -655,10 +655,10 @@ function is_focus_at_last_table_row() {return row_focus === topic_rows.length - 1;}-export function focus_clicked_element($elt, col) {+export function focus_clicked_element(topic_row_index, col) {current_focus_elem = "table";col_focus = col;- row_focus = $elt.closest("tr").index();+ row_focus = topic_row_index;// Set compose_closed_ui reply button text. The rest of the table// focus logic should be a noop.set_table_focus(row_focus, col_focus);