Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_topics: Use is_visible for testing if RT is rendered.
Aman Agrawalf95443ac8fb6
diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex a315a9c4a34..a5a4b97dac3 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -93,6 +93,9 @@ mock_esm("../../static/js/muting", {mock_esm("../../static/js/narrow", {set_narrow_title: noop,});+mock_esm("../../static/js/popovers", {+ any_active: () => false,+});mock_esm("../../static/js/recent_senders", {get_topic_recent_senders: () => [1, 2],});diff --git a/static/js/hashchange.js b/static/js/hashchange.jsindex eb7b5552776..23338b09e01 100644--- a/static/js/hashchange.js+++ b/static/js/hashchange.js@@ -65,10 +65,6 @@ function maybe_hide_recent_topics() {return false;}-export function in_recent_topics_hash() {- return ["#recent_topics"].includes(window.location.hash);-}-export function changehash(newhash) {if (browser_history.state.changing_hash) {return;diff --git a/static/js/hotkey.js b/static/js/hotkey.jsindex af8079dddeb..e8b3afbce7e 100644--- a/static/js/hotkey.js+++ b/static/js/hotkey.js@@ -222,11 +222,13 @@ 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.is_in_focus() &&+ // This will return false if `e.target` is not+ // any of the recent topics elements by design.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.+ // Recent topics uses escape to switch focus from RT search / filters to topics table.+ // If focus is already on the table it returns false.return true;}diff --git a/static/js/recent_topics.js b/static/js/recent_topics.jsindex a5d84e492a3..f380b546b0e 100644--- a/static/js/recent_topics.js+++ b/static/js/recent_topics.js@@ -8,7 +8,6 @@ import * as compose from "./compose";import * as compose_closed_ui from "./compose_closed_ui";import * as compose_state from "./compose_state";import * as hash_util from "./hash_util";-import * as hashchange from "./hashchange";import * as ListWidget from "./list_widget";import {localstorage} from "./localstorage";import * as message_store from "./message_store";@@ -75,7 +74,7 @@ export function is_in_focus() {// Check if user is focused on// recent topics.return (- hashchange.in_recent_topics_hash() &&+ is_visible() &&!compose_state.composing() &&!popovers.any_active() &&!overlays.is_active() &&