Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2634)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2635)
@@ -425,5 +425,6 @@
 
 		// Save editor selection and grab the focus.
-		this.saveSelection();
+		if ( !this._.parentDialog )
+			this.saveSelection();
 		this._.dummyText.focus();
 		this._.dummyText.$.select();
@@ -458,7 +459,14 @@
 		// Deduct or clear the z-index.
 		if ( this._.parentDialog == null )
+		{
 			CKEDITOR.dialog._.currentZIndex = null;
+
+			// Restore focus and (if not already restored) selection in the editing area.
+			this.restoreSelection();
+			this._.editor.focus();
+		}
 		else
 			CKEDITOR.dialog._.currentZIndex -= 10;
+
 	},
 
@@ -693,4 +701,5 @@
 		{
 			( new CKEDITOR.dom.selection( this._.editor.document ) ).selectRanges( this._.selectedRanges );
+			this._.selectedRanges = null;
 		}
 	}
Index: /CKEditor/branches/prototype/_source/plugins/smiley/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/smiley/plugin.js	(revision 2634)
+++ /CKEditor/branches/prototype/_source/plugins/smiley/plugin.js	(revision 2635)
@@ -72,5 +72,4 @@
 					editor.document ) );
 				this.getDialog().hide();
-				editor.focus();
 			},
 			style : 'width: 100%; height: 100%; border-collapse: separate;'
