compose: Collapse compose-box after sending message.

Previously, after sending a message from the full-sized compose-box,
the compose-box remained in expanded state covering the entire middle
part. Instead, it should return to the original state after the
message is sent.

There's a subtle race that would cause the "Scroll down to see your
message" compose notification to appear incorrectly, because the
full-size compose box occluded the entire message feed at the time the
message was locally echoed, even though it would no longer do so after
collapsing.

We address that by shrinking the compose box immediately before doing
a local echo, in addition to the primary code path in
`clear_compose_box`.  Care is taken to ensure that we avoid shrinking
the compose box when sending a message that cannot be locally echoed
and gets an error from the server.

Tested on my Ubuntu development environment, by sending empty message,
valid message and slash commands. The compose-box only shrunk on
sending valid messages.

Fixes part of #19353.
This commit is contained in:
Priyansh Garg
2021-09-23 21:13:30 +05:30
committed by Tim Abbott
parent ef84224eed
commit da2bdec4ad
2 changed files with 21 additions and 0 deletions

View File

@@ -182,6 +182,14 @@ export function create_message_object() {
}
export function clear_compose_box() {
/* Before clearing the compose box, we reset it to the
* default/normal size. Note that for locally echoed messages, we
* will have already done this action before echoing the message
* to avoid the compose box triggering "new message out of view"
* notifications incorrectly. */
if (compose_ui.is_full_size()) {
compose_ui.make_compose_box_original_size();
}
$("#compose-textarea").val("").trigger("focus");
compose_validate.check_overflow_text();
$("#compose-textarea").removeData("draft-id");