Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5411)
+++ /CKEditor/trunk/CHANGES.html	(revision 5412)
@@ -163,4 +163,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/5582">#5582</a> : Prevent the default behavior when click the 'x' button to close dialog box.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/5584">#5584</a> : Enter key with forceEnterMode turns on doesn't inherit current block attributes.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4797">#4797</a> : [Opera] Press enter key in dialog fields to close cause JavaScript error.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.fckeditor.net/ticket/5326">#5326</a> : Catalan;</li>
Index: /CKEditor/trunk/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 5411)
+++ /CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 5412)
@@ -544,4 +544,9 @@
 	CKEDITOR.dialog.prototype =
 	{
+		destroy : function()
+		{
+			this._.element.remove();
+		},
+
 		/**
 		 * Resizes the dialog.
@@ -660,5 +665,5 @@
 				element.appendTo( CKEDITOR.document.getBody() );
 			else
-				return;
+				element.setStyle( 'display', 'block' );
 
 			// FIREFOX BUG: Fix vanishing caret for Firefox 2 or Gecko 1.8.
@@ -800,13 +805,7 @@
 			this.fire( 'hide', {} );
 			this._.editor.fire( 'dialogHide', this );
-
-			// Remove the dialog's element from the root document.
 			var element = this._.element;
-			if ( !element.getParent() )
-				return;
-
-			element.remove();
+			element.setStyle( 'display', 'none' );
 			this.parts.dialog.setStyle( 'visibility', 'hidden' );
-
 			// Unregister all access keys associated with this dialog.
 			unregisterAccessKey( this );
@@ -2780,4 +2779,16 @@
 			}
 		};
+
+	CKEDITOR.on( 'instanceDestroyed', function( evt )
+	{
+		var dialogs = evt.editor._.storedDialogs;
+		for ( var name in dialogs )
+			dialogs[ name ].destroy();
+
+		// Remove dialog cover on last instance destroy.
+		if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) );
+			coverElement.remove();
+	});
+
 	})();
 })();
