editor: fix - check for success before changing current element
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 1 Apr 2014 20:18:53 +0000 (22:18 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 1 Apr 2014 20:18:53 +0000 (22:18 +0200)
src/editor/modules/documentCanvas/commands.js

index a411a37..a165132 100644 (file)
@@ -94,8 +94,13 @@ commands.register('list', function(canvas, params) {
         node2 = parent2.wlxmlNode,
         doc = node1.document;
     
         node2 = parent2.wlxmlNode,
         doc = node1.document;
     
-    doc.createList({node1: node1, node2: node2});
-    canvas.setCurrentElement(selectionFocus.element, {caretTo: selectionFocus.offset});
+    doc.transaction(function() {
+        doc.createList({node1: node1, node2: node2});
+    }, {
+        success: function() {
+            canvas.setCurrentElement(selectionFocus.element, {caretTo: selectionFocus.offset});
+        }
+    });
 });
 
 commands.register('toggle-grid', function(canvas, params) {
 });
 
 commands.register('toggle-grid', function(canvas, params) {