From 2d3e07bb05cb15a35745daea4fb9277834dff6f0 Mon Sep 17 00:00:00 2001 From: Daniel Miller Date: Thu, 8 Dec 2016 16:51:33 -0500 Subject: [PATCH] Fix change event not fired on type after paste --- plugins/undo/plugin.js | 4 ++++ tests/plugins/undo/change.js | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/plugins/undo/plugin.js b/plugins/undo/plugin.js index a9c626f7975..9fdeaffeddb 100644 --- a/plugins/undo/plugin.js +++ b/plugins/undo/plugin.js @@ -1079,6 +1079,10 @@ // It would result with calling undoManager.type() on any following key. editable.attachListener( editable, 'paste', that.ignoreInputEventListener, that, null, 999 ); editable.attachListener( editable, 'drop', that.ignoreInputEventListener, that, null, 999 ); + // After paste we need to re-enable input event listener + editor.on('afterPaste', function () { + that.ignoreInputEvent = false; + }); // Click should create a snapshot if needed, but shouldn't cause change event. // Don't pass onNavigationKey directly as a listener because it accepts one argument which diff --git a/tests/plugins/undo/change.js b/tests/plugins/undo/change.js index 6b3854e11e3..9fe8bbb9379 100644 --- a/tests/plugins/undo/change.js +++ b/tests/plugins/undo/change.js @@ -1,5 +1,5 @@ /* bender-tags: editor,unit */ -/* bender-ckeditor-plugins: undo,basicstyles,toolbar,wysiwygarea */ +/* bender-ckeditor-plugins: undo,clipboard,basicstyles,toolbar,wysiwygarea */ /* global undoEventDispatchTestsTools */ ( function() { @@ -180,6 +180,26 @@ // After setting text - caret is moved to beginning. We don't care - it does not change nothing. keyTools.keyEvent( keyCodesEnum.LEFT, null, true ); } ); + }, + + 'test change event not fired on type after paste': function() { + this.editorBot.setHtmlWithSelection( '

foo^

' ); + + var that = this, + keys = this.keyTools.keyCodesEnum; + + bender.tools.emulatePaste( this.editor, 'PASTE' ); + + this.editor.once( 'afterPaste', function() { + resume( function() { + changeCounter = 0; + that.checkChange( function() { + that.keyTools.keyEvent( keys.KEY_G ); + } ); + } ); + } ); + + wait(); } } );