recent_topics: Use is_visible for testing if RT is rendered.

We don't want to rely on browser hash to check if RT is visible
because soon we want to display default_view without any hash
and RT may or may not be visible in that hash.
This commit is contained in:
Aman Agrawal
2021-03-15 09:31:31 +00:00
committed by Tim Abbott
parent 1e63282cc2
commit f95443ac8f
4 changed files with 9 additions and 9 deletions

View File

@@ -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],
});

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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() &&