From 47fef4e3786b2040b620e1d134d47f6ca6ad6a86 Mon Sep 17 00:00:00 2001 From: Marek Lewandowski Date: Mon, 18 Aug 2014 17:23:49 +0200 Subject: [PATCH] Fixed issue with functional keys being not properly handled in IE. --- plugins/undo/plugin.js | 14 +++++++++++--- tests/plugins/undo/change.js | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/plugins/undo/plugin.js b/plugins/undo/plugin.js index 2c98e252a00..ba1261b6ebe 100644 --- a/plugins/undo/plugin.js +++ b/plugins/undo/plugin.js @@ -897,9 +897,17 @@ editor = undoManager.editor, ieFunctionKeysWorkaround = CKEDITOR.env.ie && keyCode in backspaceOrDelete; - // IE: backspace/del would still call keypress event, even if nothing was removed. - if ( ieFunctionKeysWorkaround && this.lastKeydownImage.equalsContent( new Image( editor, true ) ) ) { - return; + // IE: doesn't call keypress for backspace/del keys so we need to handle it manually + // with a workaround. + if ( ieFunctionKeysWorkaround ) { + if ( this.lastKeydownImage.equalsContent( new Image( editor, true ) ) ) { + // Content was not changed, we don't need to do anything. + return; + } else { + // Content was changed. And since no keypress event was fired, we have + // inputFired = 0, so undoManager.type method will not be called. + inputFired += 1; + } } if ( inputFired > 0 ) { diff --git a/tests/plugins/undo/change.js b/tests/plugins/undo/change.js index 828333c5617..2ebe2f496e6 100644 --- a/tests/plugins/undo/change.js +++ b/tests/plugins/undo/change.js @@ -39,6 +39,13 @@ } }, + _should: { + ignore: { + 'test backspace': CKEDITOR.env.ie, + 'test IE backspace': !CKEDITOR.env.ie + } + }, + 'test setData': function() { bender.editor.focus(); @@ -124,10 +131,18 @@ 'test backspace': function() { // IE: In case of backspace and delete we need to make real change to DOM content. + var that = this; + this.checkChange( function( editor ) { + that.keyTools.keyEvent( 8 /* backspace */ ); + } ); + }, + + 'test IE backspace': function() { + // IE doesn't send keypress event, which is used as a `input` event. var that = this, textNode = this.editor.editable().getFirst().getFirst(); this.checkChange( function( editor ) { - that.keyTools.keyEvent( 8 /* backspace */, null, null, function( e ) { + that.keyTools.keyEvent( 8 /* backspace */, null, true, function( e ) { textNode.setText( 'fo' ); } ); textNode.setText( 'foo' );