Ensure focus is returned to the event trap after an undo

This behaviour regressed in c0332ed due to the caret overlay element
being moved inside the overlay itself. As a result, the event trap was
automatically being re-added after an undo, causing the SessionController
to incorrectly skip returning focus back to the trap upon completion.
This commit is contained in:
Philip Peitsch
2014-05-21 00:28:50 +10:00
parent de909cfcbc
commit 6dc6e8a7f4
+3 -13
View File
@@ -316,23 +316,13 @@ gui.SessionControllerOptions = function () {
* @return {!boolean}
*/
function undo() {
var eventTrap = eventManager.getEventTrap(),
sizer,
hadFocusBefore;
var hadFocusBefore;
if (undoManager) {
hadFocusBefore = eventManager.hasFocus();
undoManager.moveBackward(1);
sizer = odtDocument.getOdfCanvas().getSizer();
if (!domUtils.containsNode(sizer, eventTrap)) {
// TODO Remove when a proper undo manager arrives
// The undo manager can replace the root element, discarding the original.
// The event trap node is still valid, and simply needs to be re-attached
// after this occurs.
sizer.appendChild(eventTrap);
if (hadFocusBefore) {
eventManager.focus();
}
if (hadFocusBefore) {
eventManager.focus();
}
return true;
}