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.

left_sidebar: Fix unable to type some hotkeys in expanded topic search.

Aman Agrawal7a3a5991977f
diff --git a/web/src/views_util.ts b/web/src/views_util.ts
index a9291b4fa29..639a7091589 100644
--- a/web/src/views_util.ts
+++ b/web/src/views_util.ts
@@ -150,14 +150,31 @@ export function hide(opts: {$view: JQuery; set_visible: (value: boolean) => void
}
export function is_in_focus(): boolean {
+ let can_current_view_steal_focus = true;
+ const focused_element = document.activeElement;
+ if (
+ focused_element instanceof HTMLElement &&
+ // Pill input elements.
+ (focused_element.isContentEditable ||
+ // `<input>` elements.
+ focused_element.classList.contains("input-element")) &&
+ // The input element is outside the current view.
+ // We already check for compose box via compose_state.composing().
+ focused_element.closest(".app .column-middle") === null
+ ) {
+ // If the user is focused on an input element
+ // and it is not handled by current view,
+ // then we should not steal focus from them.
+ can_current_view_steal_focus = false;
+ }
+
return (
!compose_state.composing() &&
!popovers.any_active() &&
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
!overlays.any_active() &&
!modals.any_active_or_animating() &&
- !$(".input-element:not(#recent_view_search):not(#inbox-search)").is(":focus") &&
- !$("#search_query").is(":focus") &&
+ can_current_view_steal_focus &&
!$(".navbar-item").is(":focus")
);
}