code-input icon indicating copy to clipboard operation
code-input copied to clipboard

Cursor scrolls to the top in Chrome/Edge when inserting a newline

Open zewt opened this issue 8 months ago • 1 comments

This seems the same as #72, but it's still happening for me I figured I'd open a new ticket, since that one was a while back and this might be a more specific case (everybody in that ticket seemed happy with the workaround).

It repros with the example at https://codepen.io/WebCoder49/pen/jOypJOx, or with a trivial empty editor. I can reproduce it by:

  • Insert a bunch of lines, I'm testing with 20. For some reason, the actual text seems to matter and just mashing random text doesn't always work. It happens if I insert incrementing numbers on each line, or if each line is "1", but it doesn't always happen if I just mash keys randomly.
  • Scroll the editor so it's in the middle of the text.
  • Click outside the editor to unfocus it, then click a line in the middle of the editor and press enter.

The view scrolls down, pushing the cursor to the top. No idea why it's sensitive to the actual text, but it happens to me in normal use all the time.

zewt avatar Apr 29 '25 01:04 zewt

Thanks for pointing this out! This may be related to issue #72; it also may be related to the difficulty of fixing both #93 (open) and #115 (closed) at once.

My status: I'm afraid I'm very busy right now until 21 June. I can't implement new feature requests or bugfixes myself in projects I maintain, but can merge contributions by others, especially if they fix bugs.

WebCoder49 avatar May 10 '25 11:05 WebCoder49

I was searching crbugs for this just now and ran across this: https://issues.chromium.org/issues/41477953 Looks like it was filed in 2019 and somebody claimed the bug... a few hours ago. Fingers crossed.

zewt avatar Jun 03 '25 04:06 zewt

FYI, I don't seem to be able to reproduce this anymore. (This is one of those things that's really annoying when it happens, but you don't really notice when it isn't happening...) The Chromium bug is still open, but maybe it's been fixed.

I was looking into it again since I ran across "overflow-anchor", which seems intended to work around exactly this (a scroll anchoring bug, according to the ticket) and was wondering if it would be a fix:

https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor

If it's still happening for others, that might be a workaround.

zewt avatar Aug 02 '25 20:08 zewt

Hello again, @zewt! That's amazing news that it seems fixed, and thanks for the potential workaround too!

I should probably have prioritised this and helped more, but it got lost under many other new suggestions, and I couldn't think of any fix/workaround except for solving it at the browser level.

Have a great August!

WebCoder49 avatar Aug 10 '25 16:08 WebCoder49