- // Make undo snapshot.\r
- editor.fire( 'saveSnapshot' );\r
- // Remove manually.\r
- control.remove();\r
- editor.fire( 'saveSnapshot' );\r
- evt.cancel();\r
+ var sel = editor.getSelection(),\r
+ control = sel.getSelectedElement();\r
+\r
+ if ( control )\r
+ {\r
+ // Make undo snapshot.\r
+ editor.fire( 'saveSnapshot' );\r
+\r
+ // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will\r
+ // break up the selection, safely manage it here. (#4795)\r
+ var bookmark = sel.getRanges()[ 0 ].createBookmark();\r
+ // Remove the control manually.\r
+ control.remove();\r
+ sel.selectBookmarks( [ bookmark ] );\r
+\r
+ editor.fire( 'saveSnapshot' );\r
+\r
+ evt.data.preventDefault();\r
+ }\r