Browse Source

fix: mobile app crashes while trying to swipe the block that has any collapsed block (#9154)

situ2001 2 years ago
parent
commit
67fe5dc5a7
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/main/frontend/mobile/action_bar.cljs

+ 6 - 3
src/main/frontend/mobile/action_bar.cljs

@@ -39,9 +39,12 @@
   (when-let [block (state/sub :mobile/actioned-block)]
     (let [{:block/keys [uuid children]} block
           last-child-block-id (when-not (empty? children)
-                                (-> (db/get-block-children (state/get-current-repo) uuid)
-                                    last
-                                    :block/uuid))]
+                                (->> (db/get-block-children (state/get-current-repo) uuid)
+                                     (filter #(not (db/parents-collapsed? (state/get-current-repo) (:block/uuid %1)))) ;; DOM nodes of blocks the have collapsed parents have no bounding client rect
+                                     last
+                                     :block/uuid))]
+
+      ;; scroll to the most bottom element of the selected block
       (let [tag-id (or last-child-block-id uuid)
             bottom-el (gdom/getElement (str "block-content-" tag-id))
             bottom (gobj/get (.getBoundingClientRect bottom-el) "bottom")