Sfoglia il codice sorgente

fix(ui): incorrect scrollable container for the blocks list within the right sidebar

charlie 11 mesi fa
parent
commit
3ac14d7349

+ 8 - 9
src/main/frontend/components/block.cljs

@@ -4016,7 +4016,8 @@
         *virtualized-ref (rum/use-ref nil)
         virtual-opts (when virtualized?
                        {:ref *virtualized-ref
-                        :custom-scroll-parent (gdom/getElement "main-content-container")
+                        :custom-scroll-parent (or (:scroll-container config)
+                                                (gdom/getElement "main-content-container"))
                         :compute-item-key (fn [idx]
                                             (let [block (nth blocks idx)]
                                               (str (:container-id config) "-" (:db/id block))))
@@ -4029,12 +4030,12 @@
                                               bottom? (= (dec (count blocks)) idx)
                                               block (nth blocks idx)]
                                           (block-item (assoc config :top? top?)
-                                                      block
-                                                      {:top? top?
-                                                       :bottom? bottom?})))})
+                                            block
+                                            {:top? top?
+                                             :bottom? bottom?})))})
         *wrap-ref (rum/use-ref nil)]
     (rum/use-effect!
-     (fn []
+      (fn []
        (when virtualized?
          (when (:current-page? config)
            (let [ref (.-current *virtualized-ref)]
@@ -4170,10 +4171,8 @@
      (and (:ref? config) (:group-by-page? config) (vector? (first blocks)))
      [:div.flex.flex-col.references-blocks-wrap
       (let [blocks (sort-by (comp :block/journal-day first) > blocks)
-            scroll-container (or
-                              (when-let [*ref (:scroll-container config)]
-                                (rum/deref *ref))
-                              (gdom/getElement "main-content-container"))]
+            scroll-container (or (:scroll-container config)
+                               (gdom/getElement "main-content-container"))]
         (when (seq blocks)
           (if (:sidebar? config)
             (for [block blocks]

+ 0 - 1
src/main/frontend/components/reference.cljs

@@ -49,7 +49,6 @@
     [:div.references-blocks.faster.fade-in {:ref *ref}
      (let [ref-hiccup (block/->hiccup filtered-ref-blocks
                                       {:id (str (:block/uuid page-entity))
-                                       :scroll-container *ref
                                        :ref? true
                                        :breadcrumb-show? true
                                        :group-by-page? true

+ 6 - 1
src/main/frontend/components/right_sidebar.cljs

@@ -41,11 +41,16 @@
                    :sidebar/idx idx
                    :repo        repo})))
 
+(defn get-scrollable-container
+  []
+  (js/document.querySelector ".sidebar-item-list"))
+
 (rum/defc page-cp < rum/reactive
   [repo page-name]
   (page/page-cp {:parameters {:path {:name page-name}}
                  :sidebar?   true
-                 :repo       repo}))
+                 :scroll-container (get-scrollable-container)
+                 :repo repo}))
 
 (rum/defc shortcut-settings
   []