Fix: Focus at the end of the pasted contents instead of the beginning #6427
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributor checklist:
main
branchyarn ready
run passes successfully (more about tests here)Description
When pasting a long text into the composition input, it does not scroll down to the end of the pasted text--it stays at the beginning instead. This PR changes this behaviour so that the input quill will automatically focus at the end of the text instead (i.e. scroll to the bottom of the pasted text)
I found that the problem emerged because the code calls
this.quill.focus()
before updating the contents of the quill, not after, so it would scroll to where the cursor was before the pasted text was being added, and not where it is after pasting the text. Simply callingthis.quill.focus()
after updating the contents seems to solve the problem.This fixes https://community.signalusers.org/t/when-pasting-mutliple-lines-jump-scroll-input-field-to-last-pasted-line/51677
Edit:
Here is a visual explanation of the change:
Before pasting (notice that the cursor is between two words):
After pasting, before the fix:
After pasting with the fix: