mirror of
https://github.com/webodf/WebODF.git
synced 2026-11-30 16:47:58 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user