mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
autosize_textarea() is slow, so avoid it while the user is waiting
We need to resize the textarea when it is changed via .val(). By clearing and resizing the compose box when it is closed, we can avoid calling autosize_textarea() when the user opens the compose box. This saves at least 15ms on every compose and might also be a cause of longer delays. (imported from commit fe6e092efcd1c4b95a868ee66653448f99af84c0)
This commit is contained in:
@@ -61,7 +61,6 @@ function show_box(tabname, focus_area, opts) {
|
||||
}
|
||||
$("#send-status").removeClass(status_classes).hide();
|
||||
$('#compose').css({visibility: "visible"});
|
||||
autosize_textarea();
|
||||
$(".new_message_textarea").css("min-height", "3em");
|
||||
|
||||
if (focus_area !== undefined &&
|
||||
@@ -97,6 +96,7 @@ function clear_box() {
|
||||
exports.snapshot_message();
|
||||
clear_invites();
|
||||
$("#compose").find('input[type=text], textarea').val('');
|
||||
autosize_textarea();
|
||||
$("#send-status").hide(0);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ exports.start = function (msg_type, opts) {
|
||||
|
||||
opts = fill_in_opts_from_current_narrowed_view(msg_type, opts);
|
||||
|
||||
if (!same_recipient_as_before(msg_type, opts)) {
|
||||
if (compose.composing() && !same_recipient_as_before(msg_type, opts)) {
|
||||
// Clear the compose box if the existing message is to a different recipient
|
||||
clear_box();
|
||||
}
|
||||
@@ -882,6 +882,7 @@ $(function () {
|
||||
compose.start('stream');
|
||||
}
|
||||
textbox.val(textbox.val() + contents);
|
||||
autosize_textarea();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user