Opened 8 years ago
Last modified 8 years ago
#14760 confirmed Bug
ScrollIntoView also expands selection to entire paragraph
Reported by: | David Pidcock | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 4.0 |
Keywords: | Cc: |
Description
Steps to reproduce
- With the example page, select some text (anywhere seems to work).
- Hit the button -- which runs the following code :
function scroll() { var selection = editor.getSelection(); selection.scrollIntoView(); }
Expected result
The selection is scrolled into view, but remains the same selected text.
Actual result
The selection expands to the enclosing paragraph.
Other details (browser, OS, CKEditor version, installed plugins)
Tested on Chrome
Attachments (1)
Change History (4)
Changed 8 years ago by
Attachment: | test_scrollIntoView.html added |
---|
comment:1 Changed 8 years ago by
One extra detail : the problem doesn't appear if the very first character in the paragraph is the start of the selection.
comment:2 Changed 8 years ago by
Preliminary investigation shows that the range is expanding to the paragraph at this line:
https://github.com/ckeditor/ckeditor-dev/blob/master/core/dom/range.js#L2744
I can work around this bug by restoring the selection manually.
function scroll() { var selection = editor.getSelection(); var ranges = selection.getRanges(); selection.scrollIntoView(); selection.selectRanges(ranges); }
comment:3 Changed 8 years ago by
Status: | new → confirmed |
---|---|
Version: | 4.5.10 (GitHub - master) → 4.0 |
Problem can be reproduced from CKEditor 4.0 at least in all browsers.
Your workaround is currently the only solution:
function scroll() { var selection = editor.getSelection(); var ranges = selection.getRanges(); selection.scrollIntoView(); selection.selectRanges(ranges); } //or function scroll() { var selection = editor.getSelection(); var range = selection.getRanges()[0]; selection.scrollIntoView(); range.select(); }
Minimum test example