Deleting and entering newlines (soft enter) at the end of long document causes auto-scroll to top
📝 Provide detailed reproduction steps (if any)
- Visit CKEditor demo page: https://ckeditor.com/ckeditor-5/demo/feature-rich/
- Delete all content from CKEditor field
- Paste content from attached file (long_text_file_no_html_tags.txt)
- Scroll to bottom of document
- 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
This issue could have the same underlying issue as #14605
@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?
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
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:
(Note the missing
⁠⁠... - 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>.
Where and what is the solution @Witoso ??
@Rashid101 there's none, this is an open bug on our side. Please +1 (:+1: ), the top comment.