mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
compose: Fix restoring big drafts freezes the app.
We are using `.val` to set compose box content which is very fast vs `setFieldText` which is very slow due to it doing a lot of forced repaints. The major downside of using `val` here is that user will not able to perform `undo` operation on this which doesn't seem something user would want to do here. Note that this effects compose content restored from drafts, scheduled messages and on reload.
This commit is contained in:
@@ -114,8 +114,15 @@ export function insert_and_scroll_into_view(
|
||||
content: string,
|
||||
$textarea: JQuery<HTMLTextAreaElement>,
|
||||
replace_all = false,
|
||||
replace_all_without_undo_support = false,
|
||||
): void {
|
||||
if (replace_all) {
|
||||
if (replace_all_without_undo_support) {
|
||||
// setFieldText is very slow and noticeable when inserting 10k+
|
||||
// characters of text like from a drafted response,
|
||||
// but we use it since we want to support `undo`. If we don't want
|
||||
// to support `undo`, we can use a faster method.
|
||||
$textarea.val(content);
|
||||
} else if (replace_all) {
|
||||
setFieldText($textarea[0]!, content);
|
||||
} else {
|
||||
insertTextIntoField($textarea[0]!, content);
|
||||
|
||||
Reference in New Issue
Block a user