Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 7224)
+++ /CKEditor/trunk/CHANGES.html	(revision 7225)
@@ -72,4 +72,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/7894">#7894</a> : Fault tolerance when parsing malformed link.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/8049">#8049</a> : Bullets/Numbers are invisible on list items with LTR text direction.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/8222">#8222</a> : [IE] Incorrect selection locking after open dialog in some cases.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/8128">#8128</a> : Italian;</li>
Index: /CKEditor/trunk/_source/plugins/undo/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/undo/plugin.js	(revision 7224)
+++ /CKEditor/trunk/_source/plugins/undo/plugin.js	(revision 7225)
@@ -117,15 +117,13 @@
 
 			/**
-			 * Update the undo stacks with any subsequent DOM changes after this call.
+			 * Amend the top of undo stack (last undo image) with the current DOM changes.
 			 * @name CKEDITOR.editor#updateUndo
 			 * @example
 			 * function()
 			 * {
-			 * editor.fire( 'updateSnapshot' );
-			 * ...
-			 *  // Ask to include subsequent (in this call stack) DOM changes to be
-			 * // considered as part of the first snapshot.
+			 *  editor.fire( 'saveSnapshot' );
+			 * 	editor.document.body.append(...);
+			 *  // Make new changes following the last undo snapshot part of it.
 			 * 	editor.fire( 'updateSnapshot' );
-			 * 	editor.document.body.append(...);
 			 * ...
 			 * }
@@ -133,6 +131,6 @@
 			editor.on( 'updateSnapshot', function()
 			{
-				if ( undoManager.currentImage && new Image( editor ).equals( undoManager.currentImage ) )
-					setTimeout( function() { undoManager.update(); }, 0 );
+				if ( undoManager.currentImage )
+					undoManager.update();
 			});
 		}
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 7224)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 7225)
@@ -399,6 +399,4 @@
 					&& !pathBlock.getBogus() )
 			{
-				editor.fire( 'updateSnapshot' );
-				restoreDirty( editor );
 				pathBlock.appendBogus();
 			}
@@ -413,8 +411,4 @@
 				&& !path.block )
 		{
-			editor.fire( 'updateSnapshot' );
-			restoreDirty( editor );
-			CKEDITOR.env.ie && restoreSelection( selection );
-
 			var fixedBlock = range.fixBlock( true,
 					editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p'  );
@@ -465,8 +459,4 @@
 		if ( !testPath.blockLimit.is( 'body') )
 		{
-			editor.fire( 'updateSnapshot' );
-			restoreDirty( editor );
-			CKEDITOR.env.ie && restoreSelection( selection );
-
 			var paddingBlock;
 			if ( enterMode != CKEDITOR.ENTER_BR )
@@ -1126,5 +1116,16 @@
 					editor.on( 'insertText', onInsert( doInsertText ), null, null, 20 );
 					// Auto fixing on some document structure weakness to enhance usabilities. (#3190 and #3189)
-					editor.on( 'selectionChange', onSelectionChangeFixBody, null, null, 1 );
+					editor.on( 'selectionChange', function()
+					{
+						var sel = editor.getSelection();
+						// Do it only when selection is not locked. (#8222)
+						if ( sel && !sel.isLocked )
+						{
+							var isDirty = editor.checkDirty();
+							onSelectionChangeFixBody.apply( this, arguments );
+							editor.fire( 'updateSnapshot' );
+							!isDirty && editor.resetDirty();
+						}
+					}, null, null, 1 );
 				});
 
