diff --git a/CHANGES.md b/CHANGES.md index c61fc1a2ec5..47f6dee70d9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Fixed Issues: * [#13434](http://dev.ckeditor.com/ticket/13434): Fixed: Dialog state indicator broken in Right–To–Left environments. * [#13434](http://dev.ckeditor.com/ticket/13434): [IE8-9] Fixed: One drag&drop operation may affect following ones. +* [#13129](http://dev.ckeditor.com/ticket/13129) Fixed: Block widget blurred after drop followed by undo. ## CKEditor 4.5.1 diff --git a/plugins/widget/plugin.js b/plugins/widget/plugin.js index d14a72bbf86..fb6ffd636ac 100644 --- a/plugins/widget/plugin.js +++ b/plugins/widget/plugin.js @@ -3234,12 +3234,6 @@ // and save this state as the one where we want to be taken back when undoing. this.focus(); - // Reset the fake selection, which will be invalidated by insertElementIntoRange. - // This avoids a situation when getSelection() still returns a fake selection made - // on widget which in the meantime has been moved to other place. That could cause - // an error thrown e.g. by saveSnapshot or stateUpdater. - editor.getSelection().reset(); - // Drag range will be set in the drop listener. editor.fire( 'drop', { dropRange: dropRange, diff --git a/tests/plugins/widget/dnd.js b/tests/plugins/widget/dnd.js index 994878ca0db..dd108d8aaef 100644 --- a/tests/plugins/widget/dnd.js +++ b/tests/plugins/widget/dnd.js @@ -448,6 +448,9 @@ editor.focus(); try { + // Testing if widget is selected is meaningful only if it is not selected at the beginning. (#13129) + assert.isNull( editor.widgets.focused, 'widget not focused before mousedown' ); + img.fire( 'mousedown' ); // Create dummy line and pretend it's visible to cheat drop listener @@ -456,12 +459,18 @@ editor.document.fire( 'mouseup' ); + assert.areSame( widget, editor.widgets.focused, 'widget focused after mouseup' ); + bender.tools.resumeAfter( editor, 'afterPaste', function() { assert.isTrue( pasteCounter.calledOnce, 'paste called once' ); assert.isTrue( dragstartCounter.calledOnce, 'dragstart called once' ); assert.isTrue( dragendCounter.calledOnce, 'dragend called once' ); assert.isTrue( dropCounter.calledOnce, 'drop called once' ); assert.areSame( '
bar

foo

', editor.getData(), 'Widget moved on drop.' ); + + // Check if widget is still selected after undo. (#13129) + editor.execCommand( 'undo' ); + assert.areSame( getWidgetById( editor, 'w1' ), editor.widgets.focused, 'widget focused after undo' ); } ); wait(); @@ -541,4 +550,4 @@ } ); } } ); -} )(); \ No newline at end of file +} )();