From ce58110cc705b2280e04c8aef29bb693afd98fd8 Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Wed, 24 Jun 2015 12:38:55 +0200 Subject: [PATCH 1/4] Fixed: widget not selected after D&D and undo. --- plugins/widget/plugin.js | 6 ------ tests/plugins/widget/dnd.js | 11 ++++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) 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..36d939bd033 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.isFalse( !!editor.getSelection().isFake, 'widget was focused on 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.isTrue( !!editor.getSelection().isFake, 'widget was not focused on 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.isTrue( !!editor.getSelection().isFake, 'widget was not focused after undo' ); } ); wait(); @@ -541,4 +550,4 @@ } ); } } ); -} )(); \ No newline at end of file +} )(); From 27baa8dbbc4eb3c236e5b82d424a325d00723912 Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Mon, 6 Jul 2015 15:15:14 +0200 Subject: [PATCH 2/4] Tests: drag and drop - tweaked assertions. --- tests/plugins/widget/dnd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/plugins/widget/dnd.js b/tests/plugins/widget/dnd.js index 36d939bd033..105fe1c2f76 100644 --- a/tests/plugins/widget/dnd.js +++ b/tests/plugins/widget/dnd.js @@ -449,7 +449,7 @@ try { // Testing if widget is selected is meaningful only if it is not selected at the beginning. (#13129) - assert.isFalse( !!editor.getSelection().isFake, 'widget was focused on mousedown' ); + assert.isNull( editor.widgets.focused , 'widget was not focused on mousedown' ); img.fire( 'mousedown' ); @@ -459,7 +459,7 @@ editor.document.fire( 'mouseup' ); - assert.isTrue( !!editor.getSelection().isFake, 'widget was not focused on mouseup' ); + assert.areSame( widget, editor.widgets.focused, 'widget was not focused on mouseup' ); bender.tools.resumeAfter( editor, 'afterPaste', function() { assert.isTrue( pasteCounter.calledOnce, 'paste called once' ); @@ -470,7 +470,7 @@ // Check if widget is still selected after undo. (#13129) editor.execCommand( 'undo' ); - assert.isTrue( !!editor.getSelection().isFake, 'widget was not focused after undo' ); + assert.areSame( getWidgetById( editor, 'w1' ), editor.widgets.focused, 'widget was focused after undo' ); } ); wait(); From 7fc984c266a9b621bdb4695cd14a7a7f9063a6ed Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 6 Jul 2015 15:47:37 +0200 Subject: [PATCH 3/4] Fixed assertion messages in block widget dnd test. --- tests/plugins/widget/dnd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/plugins/widget/dnd.js b/tests/plugins/widget/dnd.js index 105fe1c2f76..dd108d8aaef 100644 --- a/tests/plugins/widget/dnd.js +++ b/tests/plugins/widget/dnd.js @@ -449,7 +449,7 @@ try { // Testing if widget is selected is meaningful only if it is not selected at the beginning. (#13129) - assert.isNull( editor.widgets.focused , 'widget was not focused on mousedown' ); + assert.isNull( editor.widgets.focused, 'widget not focused before mousedown' ); img.fire( 'mousedown' ); @@ -459,7 +459,7 @@ editor.document.fire( 'mouseup' ); - assert.areSame( widget, editor.widgets.focused, 'widget was not focused on mouseup' ); + assert.areSame( widget, editor.widgets.focused, 'widget focused after mouseup' ); bender.tools.resumeAfter( editor, 'afterPaste', function() { assert.isTrue( pasteCounter.calledOnce, 'paste called once' ); @@ -470,7 +470,7 @@ // Check if widget is still selected after undo. (#13129) editor.execCommand( 'undo' ); - assert.areSame( getWidgetById( editor, 'w1' ), editor.widgets.focused, 'widget was focused after undo' ); + assert.areSame( getWidgetById( editor, 'w1' ), editor.widgets.focused, 'widget focused after undo' ); } ); wait(); From 89c1cc7b9b4701e2ff6f5d532e3a7cd651edb98d Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 6 Jul 2015 15:55:00 +0200 Subject: [PATCH 4/4] Changelog entry. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) 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