ckeditor4 icon indicating copy to clipboard operation
ckeditor4 copied to clipboard

range.scrollIntoView() modify range of text selection

Open msamsel opened this issue 6 years ago • 1 comments

Are you reporting a feature request or a bug?

BUG

Provide detailed reproduction steps (if any)

  1. 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-L2815

Expected result

range remain unchanged

Actual result

range is changed

Other details

  • Browser: All
  • OS: All
  • CKEditor version: 4.9.2
  • Installed CKEditor plugins: …

msamsel avatar May 07 '18 15:05 msamsel

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.

Jamby93 avatar Jul 07 '22 07:07 Jamby93