-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API edits cause the document to jump to cursor location #1152
Comments
To clarify step 3 is use an API call? And more specifically an API call where source == 'api' |
Yes, I'm using the sharedb/quill example provided by sharedb. I'm calling updateContents(delta) when an op event is received. I'm not setting the source, but looks like it defaults to 'api' per the quill documentation. |
With this fix applied and my authorship module registered, it causes the cursor to jump to the beginning of the span when there is an API update in the middle of that span. Is it possible to move the check for source === Emitter.sources.USER from modify and add it to setSelection so that it doesn't call scrollIntoView() unless the source is a user? That fixes the issue for me. |
So you're saying setSelection(range, "api") is causing jumps? |
No, its actually not calling setSelection because source != Emitter.sources.USER in the modify function. I'm calling updateContents without a source so its defaulting to "api". It doesn't jump prior to the "only restore selection for user changes" commit. To fix the original issue about scrolling to the cursor on api changes, I think we still need to update the cursor location on api changes, just not scroll to the cursor, which is why I suggested not calling scrollIntoView from setSelection unless the source is "user". |
I see--it does make sense to not have the check in |
Yes, that makes most sense since setSelection is called with source === "silent". |
It may be the case the user's cursor is on a bold (or any other) blot and an api call removes the format which would lose the selection. Related #1152
Hello how to solve such a problem @sbevels |
This is an annoyance when reading the document. If your cursor is at the top of the document and you scroll down to the bottom of the document, you are immediately moved back up to where your cursor is at the top of the document when it is edited. This does not allow a user to read sections of a document without moving their cursor as they read.
Steps for Reproduction
Expected behavior:
User is not returned to cursor location if the user is not actively typing.
Actual behavior:
User is returned to cursor location.
Platforms:
Firefox, windows
Version:
1.1.5
The text was updated successfully, but these errors were encountered: