ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Deleting and entering newlines (soft enter) at the end of long document causes auto-scroll to top

Open tomcdonnell opened this issue 2 years ago • 6 comments

📝 Provide detailed reproduction steps (if any)

  1. Visit CKEditor demo page: https://ckeditor.com/ckeditor-5/demo/feature-rich/
  2. Delete all content from CKEditor field
  3. Paste content from attached file (long_text_file_no_html_tags.txt)
  4. Scroll to bottom of document
  5. Press backspace a few times until a newline is deleted.

✔️ Expected result

No auto-scrolling occurs

❌ Actual result

The page auto-scrolls to the top of the CKEditor field. (See attached video file for video demonstration)

📃 Other details

  • Browser: Firefox 111.0.1 (64-bit)
  • OS: Ubuntu 22.04.2 LTS
  • First affected CKEditor version: Don't know
  • Installed CKEditor plugins: None I think since bug occurs on demo page

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

ckeditor_autoscroll_bug_on_demo_page.webm long_text_file_no_html_tags.txt

tomcdonnell avatar May 04 '23 06:05 tomcdonnell

This issue could have the same underlying issue as #14605

mlewand avatar Jul 27 '23 14:07 mlewand

@mlewand AFAICS it happens when the selection lands after delete at the end of a soft brake. The same case as in a code block, right?

Witoso avatar Jul 31 '23 10:07 Witoso

This is happening because this code can't resolve proper client rect and falls back to parent container bounding rect:

https://github.com/ckeditor/ckeditor5/blob/cfab99d31251d7da34698ca267151fdefe150d6e/packages/ckeditor5-utils/src/dom/rect.ts#L386-L407

niegowski avatar Jul 31 '23 11:07 niegowski

After a deeper checking, I noticed that the range.getClientRects() has a problem resolving screen coordinates if the range is not attached to any text node. In the case of <br/>[]<br/> it fails to return client rect. I noticed that it happens only in the last line (before the final <br> - a block filler). In the other lines there is an inline filler and client rects are resolved properly: 2023-08-22 16 53 48 (Note the missing &NoBreak;&NoBreak;... - an inline filler, before the block filler)

The line responsible for not adding an inline filler is:

https://github.com/ckeditor/ckeditor5/blob/5028271b1b8d8825d6c7b266b9c9f4e7fe0d1c25/packages/ckeditor5-engine/src/view/renderer.ts#L525-L528

And while checking the getFillerOffset() of the ContainerElement I noticed that it was updated to support block filler after the last <br>:

https://github.com/ckeditor/ckeditor5/blob/5028271b1b8d8825d6c7b266b9c9f4e7fe0d1c25/packages/ckeditor5-engine/src/view/containerelement.ts#L83-L86

but this was not applied to the inline filler logic that should allow for inline filler next to a block filler if this is after another <br>.

niegowski avatar Aug 22 '23 15:08 niegowski

Where and what is the solution @Witoso ??

Rashid101 avatar Sep 13 '23 13:09 Rashid101

@Rashid101 there's none, this is an open bug on our side. Please +1 (:+1: ), the top comment.

Witoso avatar Sep 13 '23 14:09 Witoso