PERF: Update maybeContinueList to avoid replacing the entire post (#29416)

Using execCommand to replace the entire contents of the textarea is very slow for larger posts (it seems the browser does a reflow after every 'virtual keypress').

This commit updates the `maybeContinueList()` function to be more surgical when removing the bullet. Now it only selects & removes the characters which actually need to be deleted

Similar to a7cd220704
This commit is contained in:
David Taylor 2024-10-25 16:37:09 +01:00 committed by GitHub
parent 5b7df76248
commit 3076b6e8d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -619,11 +619,7 @@ export default class TextareaTextManipulation {
} else {
// Clear the new autocompleted list item if there is no other text.
const offsetWithoutPrefix = offset - `\n${listPrefix}`.length;
this.replaceText(
text,
text.substring(0, offsetWithoutPrefix) + text.substring(offset),
{ skipNewSelection: true }
);
this._insertAt(offsetWithoutPrefix, offset, "");
this.selectText(offsetWithoutPrefix, 0);
}
}