-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Chrome - removing lines when the editor (vertical) scrollbar is close to the end makes the page scrolls #721
Comments
This looks like some very obscure Chrome misbehavior—it randomly moves the scroll position of the window as the editor updates its internal DOM (the scroll happens during the |
Thanks for your analysis. Let me know if I can be of any help 🤗 |
The behavior seems to be related to where the selection is—I could suppress the problem as it is caused by the doc DOM update by moving the selection out of the deleted line before removing it. But I didn't find a way to avoid the issue with I spent a bit of time trying to set up a CodeMirror-less contentEditable div that triggers this, but didn't succeed, so though the effect happens precisely on innocent-looking DOM changes, it's possible that some other factor, which I haven't identified yet, is also involved. |
commenting line 380 on editorview.ts resolves the issue there is an odd behavior where if you are at the top of the screen it will not trigger. This suggested to me to be part of CodeMirror's code and not the browser reacting to DOM. There should be logic here to determine the y value of active line or whatever and check if it is already in the display window. |
Are you sure? The scroll doesn't originate there for me, but rather during the DOM manipulations for the content update. |
you are right. A hack could be to record document.scrollingElement.scrollTop and reset it after the update.. |
Is there a workaround ? |
I found a way. |
In the following screen-cast, I'm inserting blank lines using
<Enter>
and removing them using<Del>
:As you can see, the page is scrolling.
I cannot reproduce this issue on Firefox 96.
Chrome version 98.0.4758.80 (64 bits) on Linux.
The text was updated successfully, but these errors were encountered: