Opened 12 years ago

Closed 12 years ago

#8435 closed Bug (invalid)

IE 7/8 Cannot get text selection for the first time

Reported by: Wilfrid Li Owned by:
Priority: Normal Milestone:
Component: Core : Selection Version:
Keywords: Cc:


There is a bug in the latest CKEditor release (3.6.2), where CKEditor cannot obtain the text selection (either selected via 'doubleclick' or 'mouse drag from A to B') under IE (either 7 or 8, not sure about 9 and 10). I managed to recreate the issue here:

Select some text in the middle of the sentence, 'text' for example. Click on the yellow icon in the middle of the toolbars, it will open up an iframe dialog. Type in anything in the text box and click 'insert link'. If you debug the javascript, you'll see mySelection.getNative().createRange().text == ""

If you undo the changes in CKEditor and try to insert the text again on the same word, the selection will work as normal.

The following bug above applies to any text the user hasn't previously selected.

The test case files can be downloaded in the link below:

Attachments (1)

testplugin.html (1.9 KB) - added by Jakub Ś 12 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 12 years ago by Wilfrid Li

This bug is has caused one of my major project stalled for weeks now, can I get someone to give me a reply about this issue and if there's anyway to bypass this issue?


comment:2 Changed 12 years ago by Wilfrid Li

I debugged the source code for CKEditor and have found a solution (I think):

When we call mySelection.unlock(true)

  • it calls the function 'unlock' in the 'selection' plugin
  • doc.getBody().focus(); [function 'unlock' - line 1312], eventually calls ''
  • ieRange within '' returned the appropriate selected text for the first time
  • However, when this.selectRanges(ranges) runs [function 'unlock' - line 1317], the code somehow tries to getSelection again through ''
  • this created start/end bookmark right next to each other in the html and thus overwritten the first getSelection attempt made by 'doc.getBody().focus();'
  • removing line 1312 'doc.getBody().focus();' fixes the issue.
  • I'm not sure if that will break anything else though...

comment:3 Changed 12 years ago by Jakub Ś

Keywords: IE Selection Bug removed
Resolution: invalid
Status: newclosed
Version: 3.6.2

Have you tried to use hgetSelectedText() method?

I had made some changes to your code and had no problems with getting the code to work as expected. Please see attachment.

Closing the ticket as invalid.

Version 0, edited 12 years ago by Jakub Ś (next)

Changed 12 years ago by Jakub Ś

Attachment: testplugin.html added
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy