                            documents))))
 
 (defn menu-item-dialog-callback [feeds documents parent-el e]
-  (if (= "ok" (.-key e))
-    (let [nested (classes/has parent-el "new-node")
-          new-link-details (menu-item-link-details-from-dialog!)
-          menu-container-el (dom/getElement "menu-container")
-          active-el (or parent-el menu-container-el)]
-      (validate-link-label! (:label new-link-details))
-      (if (classes/has (dom/getElement "add-link-status") "error")
-        (do
-          (. e (preventDefault))
-          (when-not (menu-container-el? active-el)
-            (dom/removeNode active-el)))
-        (do
-          (classes/remove parent-el "new-node")
+  (. e (preventDefault))
+ 
+  (let [active-el (or parent-el menu-container-el)]
+    (if (= "ok" (.-key e))
+      (let [nested (classes/has parent-el "new-node")
+            new-link-details (menu-item-link-details-from-dialog!)
+            menu-container-el (dom/getElement "menu-container")]
+        (validate-link-label! (:label new-link-details))
+        (when-not (classes/has (dom/getElement "add-link-status") "error")
           (let [dummy-el (dom/createElement "ul")]
+            (classes/remove parent-el "new-node")
             (set! (.-innerHTML dummy-el)
                   (ui/render-template-as-string tpl/menu-item-li
                                                 new-link-details))

                       (get-related-images
                        (dom/getElement "related-images-container")))}))

(defn save-new-document-xhr-callback [e]
  (let [xhr (.-target e)]
    (if (= (.getStatus xhr e) 201)

                               (.-target evt)))
                             evt))))

(defn make-menu-builder-sortable [feeds documents]
  (let [menu-container-el (dom/getElement "menu-container")]
    (ui/to-sortable-tree (dom/getElement menu-container-el)
