Opened 6 years ago

Closed 6 years ago

#10055 closed Bug (fixed)

CKEditor backspace IE - When selecting a image and pressing "backspace" causes browser to go back

Reported by: Roy Shoa Owned by: Piotrek Koszuliński
Priority: Normal Milestone: CKEditor 4.3.1
Component: General Version: 4.0
Keywords: IE IBM Cc: mmgagnon@…, jean-francois.fournier@…, satya_minnekanti@…, mike@…

Description

Hi, When selecting a image and pressing "backspace" causes browser to go back instead of removing the image.

Steps to Reproduce

  1. Open IE9 browser.
  2. Go to "http://ckeditor.com/demo".
  3. Select the image on in the editor by clicking on it.
  4. Press "backspace".

Expected Result

The image need to be removed.

Actual Result

browser to go back.

Change History (15)

comment:1 Changed 6 years ago by Roy Shoa

I am getting the same result in IE8.

comment:2 Changed 6 years ago by Jakub Ś

Keywords: backspace remove image removed
Status: newconfirmed
Version: 4.0.14.0

This problem can be reproduced in IE7-10 from CKEditor 4.0. It doesn't occur in CKE 4 beta and CKE 3.x (it was fixed with #4047).

comment:3 Changed 6 years ago by Mathieu Marcotte

Cc: mmgagnon@… added
Version: 4.04.1.1

This bug can still be reproduced with ckEditor 4.1.x, and occurs in both Internet Explorer 9 and 10.

comment:4 Changed 6 years ago by Mathieu Marcotte

This is not the cleanest solution ever, but in case this can help anyone facing this issue, here is the best workaround I could come up with until a proper solution is found. This does not currently work for inline editing but can likely be adapted without too much trouble

    /** Work around Internet Explorer bug : the backspace key is interpreted as a keyboard shortcut to navigate back */
    function preventBackspaceFromNavigatingInCkEditor(ckId)
    {
        var iframe = $('#cke_' + ckId + ' .cke_wysiwyg_frame');
        $(iframe[0].contentWindow.document).keydown(function (e)
        {
            var preventKeyPress;
            if (e.keyCode == 8)
            {
                var range = CKEDITOR.instances[ckId].getSelection().getRanges()[0];
                if (range == null) return;
                var node = range.getEnclosedNode();
                if (node == null) return;

                if (node.$ != null)
                {
                    var nodeName = node.$.tagName.toUpperCase();
                    if (nodeName == "IMG" || nodeName == "TABLE" || nodeName == "A")
                    {
                        preventKeyPress = true;

                        // erase selection
                        range.deleteContents();
                        range.select(); 
                    }
                }
            }
            else
                preventKeyPress = false;

            if (preventKeyPress)
                e.preventDefault();
        });
    }

comment:5 Changed 6 years ago by Jakub Ś

Version: 4.1.14.0

@mmgagnon version is used to indicate when problem stared occurring. Don't change it!!!

comment:6 Changed 6 years ago by Jakub Ś

Cc: jean-francois.fournier@… added

#10313 was marked as duplicate.

comment:7 Changed 6 years ago by Satya Minnekanti

Cc: satya_minnekanti@… added
Keywords: IBM added

comment:8 Changed 6 years ago by Mike Burgh

Cc: mike@… added

CC

comment:9 Changed 6 years ago by Piotrek Koszuliński

Owner: set to Piotrek Koszuliński
Status: confirmedassigned

comment:10 Changed 6 years ago by Piotrek Koszuliński

First bad commit: git:a930e53.

comment:11 Changed 6 years ago by Piotrek Koszuliński

Status: assignedreview

Pushed t/10055 which re enable custom image/anchor/etc delete code. I decided to cover only browsers affected by this bug.

The code which removes selected element is poor - it loses selection or places it between blocks or does not autoparagraph (usually in case of table/list selection). There's similar code which handles widgets and it works better, but it's not perfect too. So, since we're planning to rewrite all backspace/delete handling, I'm not touching that part.

comment:12 Changed 6 years ago by Piotrek Koszuliński

Reported #11221 with the follow up.

comment:13 Changed 6 years ago by Piotrek Koszuliński

Duplicate was reported #11235.

comment:14 Changed 6 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 4.3.1
Status: reviewreview_passed

comment:15 Changed 6 years ago by Piotrek Koszuliński

Resolution: fixed
Status: review_passedclosed

Fixed on master with git:a1baa1d.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy