Skip to content

Commit

Permalink
Fix change event not fired on type after paste
Browse files Browse the repository at this point in the history
  • Loading branch information
millerdev committed Jan 5, 2017
1 parent 8437204 commit 2d3e07b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plugins/undo/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion tests/plugins/undo/change.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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( '<p>foo^</p>' );

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();
}
} );

Expand Down

0 comments on commit 2d3e07b

Please sign in to comment.