diff --git a/web/src/hotkey.js b/web/src/hotkey.js index c4bf376939..e49ccdbe9c 100644 --- a/web/src/hotkey.js +++ b/web/src/hotkey.js @@ -35,6 +35,7 @@ import * as narrow from "./narrow"; import * as narrow_state from "./narrow_state"; import * as navigate from "./navigate"; import * as overlays from "./overlays"; +import * as overlays_modals from "./overlays_modals"; import {page_params} from "./page_params"; import * as playground_links_popover from "./playground_links_popover"; import * as popover_menus from "./popover_menus"; @@ -861,7 +862,7 @@ export function process_hotkey(e, hotkey) { } // Prevent navigation in the background when the overlays are active. - if (overlays.is_overlay_or_modal_open()) { + if (overlays_modals.any_active()) { if (event_name === "view_selected_stream" && overlays.streams_open()) { stream_settings_ui.view_stream(); return true; diff --git a/web/src/inbox_ui.js b/web/src/inbox_ui.js index e8f68ef571..b673b7a1fc 100644 --- a/web/src/inbox_ui.js +++ b/web/src/inbox_ui.js @@ -15,7 +15,7 @@ import * as keydown_util from "./keydown_util"; import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area"; import {localstorage} from "./localstorage"; import * as message_store from "./message_store"; -import * as overlays from "./overlays"; +import * as overlays_modals from "./overlays_modals"; import {page_params} from "./page_params"; import * as people from "./people"; import * as popovers from "./popovers"; @@ -1191,7 +1191,7 @@ export function is_in_focus() { !compose_state.composing() && !popovers.any_active() && !sidebar_ui.any_sidebar_expanded_as_overlay() && - !overlays.is_overlay_or_modal_open() && + !overlays_modals.any_active() && !$(".home-page-input").is(":focus") ); } diff --git a/web/src/overlays.ts b/web/src/overlays.ts index 49847c3290..068c7dbf99 100644 --- a/web/src/overlays.ts +++ b/web/src/overlays.ts @@ -61,10 +61,6 @@ export function is_modal_open(): boolean { return $(".micromodal").hasClass("modal--open"); } -export function is_overlay_or_modal_open(): boolean { - return is_active() || is_modal_open(); -} - export function info_overlay_open(): boolean { return open_overlay_name === "informationalOverlays"; } diff --git a/web/src/overlays_modals.ts b/web/src/overlays_modals.ts new file mode 100644 index 0000000000..a24958ea35 --- /dev/null +++ b/web/src/overlays_modals.ts @@ -0,0 +1,5 @@ +import * as overlays from './overlays'; + +export function any_active(): boolean { + return overlays.is_active() || overlays.is_modal_open(); +} diff --git a/web/src/recent_view_ui.js b/web/src/recent_view_ui.js index 55de3704d1..734fe09ea1 100644 --- a/web/src/recent_view_ui.js +++ b/web/src/recent_view_ui.js @@ -19,7 +19,7 @@ import {localstorage} from "./localstorage"; import * as message_store from "./message_store"; import * as message_util from "./message_util"; import * as muted_users from "./muted_users"; -import * as overlays from "./overlays"; +import * as overlays_modals from "./overlays_modals"; import {page_params} from "./page_params"; import * as people from "./people"; import * as popovers from "./popovers"; @@ -103,7 +103,7 @@ export function is_in_focus() { !compose_state.composing() && !popovers.any_active() && !sidebar_ui.any_sidebar_expanded_as_overlay() && - !overlays.is_overlay_or_modal_open() && + !overlays_modals.any_active() && !$(".home-page-input").is(":focus") ); } diff --git a/web/src/ui_init.js b/web/src/ui_init.js index ec843ab9df..2b861d1d52 100644 --- a/web/src/ui_init.js +++ b/web/src/ui_init.js @@ -76,6 +76,7 @@ import * as narrow_title from "./narrow_title"; import * as navbar_alerts from "./navbar_alerts"; import * as navigate from "./navigate"; import * as overlays from "./overlays"; +import * as overlays_modals from "./overlays_modals"; import {page_params} from "./page_params"; import * as people from "./people"; import * as playground_links_popover from "./playground_links_popover"; @@ -249,7 +250,7 @@ export function initialize_kitchen_sink_stuff() { message_viewport.$scroll_container.on("wheel", (e) => { const delta = e.originalEvent.deltaY; - if (!overlays.is_overlay_or_modal_open() && narrow_state.is_message_feed_visible()) { + if (!overlays_modals.any_active() && narrow_state.is_message_feed_visible()) { // In the message view, we use a throttled mousewheel handler. throttled_mousewheelhandler(e, delta); } diff --git a/web/src/unread_ops.js b/web/src/unread_ops.js index 936a601d66..ae26b732f2 100644 --- a/web/src/unread_ops.js +++ b/web/src/unread_ops.js @@ -14,7 +14,7 @@ import * as message_lists from "./message_lists"; import * as message_store from "./message_store"; import * as message_viewport from "./message_viewport"; import * as narrow_state from "./narrow_state"; -import * as overlays from "./overlays"; +import * as overlays_modals from "./overlays_modals"; import * as people from "./people"; import * as recent_view_ui from "./recent_view_ui"; import * as ui_report from "./ui_report"; @@ -471,7 +471,7 @@ export function mark_pm_as_read(user_ids_string) { export function viewport_is_visible_and_focused() { if ( - overlays.is_overlay_or_modal_open() || + overlays_modals.any_active() || !is_window_focused() || !$("#message_feed_container").is(":visible") ) { diff --git a/web/tests/hotkey.test.js b/web/tests/hotkey.test.js index dac2656f60..d2134b48ce 100644 --- a/web/tests/hotkey.test.js +++ b/web/tests/hotkey.test.js @@ -65,7 +65,6 @@ const overlays = mock_esm("../src/overlays", { info_overlay_open: () => false, is_modal_open: () => false, active_modal: () => undefined, - is_overlay_or_modal_open: () => overlays.is_modal_open() || overlays.is_active(), }); const popovers = mock_esm("../src/user_card_popover", { manage_menu: {