Open msamsel opened 6 years ago
Still present as of CKEditor 4.19.0... scrollIntoView seems completely unusable with this issue. See https://plnkr.co/edit/js7F4RMPzMYi59ak as a minimal example. Try select a word then click "Scroll into view": whole paragraph is highlighted. If you simply place the cursor in the middle of any paragraph, after scrollIntoView, the cursor is moved to the start of the paragraph.
It can be worked around using something like this:
const selection = editor.getSelection(); const ranges = selection.getRanges(); selection.scrollIntoView(); selection.selectRanges(ranges);
It still feels a pretty odd way to preserve ranges.
Are you reporting a feature request or a bug?
BUG
Provide detailed reproduction steps (if any)
range.scrollIntoView
for selected text node modifies its range, because set new text of node: https://github.com/ckeditor/ckeditor-dev/blob/c413b2d33d3fc67c111c2db2f485020afaeeaa60/core/dom/range.js#L2812-L2815Expected result
range remain unchanged
Actual result
range is changed
Other details