Browse Source

fix: should remove the :collapse property when the block is opened in the sidebar

shidenggui 4 years ago
parent
commit
494532e95b
1 changed files with 14 additions and 11 deletions
  1. 14 11
      src/main/frontend/components/block.cljs

+ 14 - 11
src/main/frontend/components/block.cljs

@@ -1336,17 +1336,20 @@
 
 (defn- bullet-on-click
   [e block uuid]
-  (if (-> block :block/properties :collapsed)
-    (editor-handler/expand-all! uuid (:block/level block)))
-  (if (gobj/get e "shiftKey")
-    (do
-      (state/sidebar-add-block!
-       (state/get-current-repo)
-       (:db/id block)
-       :block
-       block)
-      (util/stop e))
-    (route-handler/redirect-to-page! uuid)))
+  (let [block (if (-> block :block/properties :collapsed)
+                (do (editor-handler/expand-block! uuid)
+                    (update-in block [:block/properties] dissoc :collapsed))
+               block)]
+    (if (gobj/get e "shiftKey")
+      (do
+        (state/sidebar-add-block!
+          (state/get-current-repo)
+          (:db/id block)
+          :block
+          block)
+        (util/stop e))
+      (route-handler/redirect-to-page! uuid))
+    ))
 
 (defn- block-left-border-on-click
   [e children]