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: Move focus to search box on click.

Aman Agrawaldef045c29db6
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 657d224acea..0bd984c3ac0 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -367,6 +367,11 @@ exports.initialize = function () {
// RECENT TOPICS
+ $('body').on('click', '#recent_topics_search', function (e) {
+ e.stopPropagation();
+ recent_topics.change_focused_element(e, 'click');
+ });
+
$('body').on('click', '.on_hover_topic_read', function (e) {
e.stopPropagation();
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js
index 6eeae076fa5..819942ca987 100644
--- a/static/js/recent_topics.js
+++ b/static/js/recent_topics.js
@@ -476,6 +476,15 @@ exports.change_focused_element = function (e, input_key) {
case 'down_arrow':
set_table_focus(row_focus, col_focus);
return true;
+ case 'click':
+ // Note: current_focus_elem can be different here, so we just
+ // set current_focus_elem to the input box, we don't want .focus() on
+ // it since it is already focused.
+ // We only do this for search beacuse we don't want the focus to
+ // go away from the input box when `revive_current_focus` is called
+ // on rerender when user is typing.
+ current_focus_elem = $("#recent_topics_search");
+ return true;
}
} else if ($elem.hasClass('btn-recent-filters')) {
switch (input_key) {