Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow: Open compose box before rendering main message feed.
Tim Abbott7d4ec1f93bc3
diff --git a/web/src/compose_actions.js b/web/src/compose_actions.jsindex 526a666ee30..a4eabbf5788 100644--- a/web/src/compose_actions.js+++ b/web/src/compose_actions.js@@ -90,11 +90,11 @@ function clear_box() {$(".compose_control_button_container:has(.add-poll)").removeClass("disabled-on-hover");}-export function autosize_message_content() {+export function autosize_message_content(opts) {if (!compose_ui.is_full_size()) {autosize($("textarea#compose-textarea"), {callback() {- maybe_scroll_up_selected_message();+ maybe_scroll_up_selected_message(opts);},});}@@ -112,7 +112,7 @@ export function complete_starting_tasks(msg_type, opts) {// by compose.start() for now. Having this as a separate function// makes testing a bit easier.- maybe_scroll_up_selected_message();+ maybe_scroll_up_selected_message(opts);compose_fade.start_compose(msg_type);if (msg_type === "stream") {stream_bar.decorate(@@ -125,7 +125,11 @@ export function complete_starting_tasks(msg_type, opts) {compose_recipient.update_narrow_to_recipient_visibility();}-export function maybe_scroll_up_selected_message() {+export function maybe_scroll_up_selected_message(opts) {+ if (!opts.skip_scrolling_selected_message) {+ return;+ }+// If the compose box is obscuring the currently selected message,// scroll up until the message is no longer occluded.if (message_lists.current.selected_id() === -1) {@@ -194,7 +198,7 @@ export function start(msg_type, opts) {}popovers.hide_all();- autosize_message_content();+ autosize_message_content(opts);if (reload_state.is_in_progress()) {return;@@ -456,7 +460,14 @@ export function on_narrow(opts) {return;}}- start("private");++ // Open the compose box, passing the option to skip attempting+ // an animated adjustment to scroll position, which is useless+ // because we are called before the narrowing process has set+ // the view's scroll position. recenter_view is responsible+ // for taking the open compose box into account when placing+ // the selecting message.+ start("private", {skip_scrolling_selected_message: true});return;}diff --git a/web/src/narrow.js b/web/src/narrow.jsindex f73f7269b3e..3a8b574e4ae 100644--- a/web/src/narrow.js+++ b/web/src/narrow.js@@ -508,6 +508,13 @@ export function activate(raw_terms, opts) {});}+ // Important: We need to consider opening the compose box+ // before calling update_selection, so that the logic in+ // recenter_view for positioning the currently selected+ // message can take into account the space consumed by the+ // open compose box.+ compose_actions.on_narrow(opts);+if (select_immediately) {update_selection({id_info,@@ -525,7 +532,6 @@ export function activate(raw_terms, opts) {handle_post_view_change(msg_list);- compose_actions.on_narrow(opts);unread_ui.update_unread_banner();diff --git a/web/tests/narrow_activate.test.js b/web/tests/narrow_activate.test.jsindex 1a52daf00f8..ac24eb1d946 100644--- a/web/tests/narrow_activate.test.js+++ b/web/tests/narrow_activate.test.js@@ -215,6 +215,7 @@ run_test("basics", ({override}) => {[message_feed_loading, "hide_indicators"],[message_lists, "save_pre_narrow_offset_for_reload"],[compose_banner, "clear_message_sent_banners"],+ [compose_actions, "on_narrow"],[unread_ops, "process_visible"],[narrow_history, "save_narrow_state_and_flush"],[message_viewport, "stop_auto_scrolling"],@@ -226,7 +227,6 @@ run_test("basics", ({override}) => {[narrow_title, "update_narrow_title"],[left_sidebar_navigation_area, "handle_narrow_activated"],[stream_list, "handle_narrow_activated"],- [compose_actions, "on_narrow"],[compose_recipient, "handle_middle_pane_transition"],]);