Browse Source

fix: scroll in sidebar

Tienson Qin 8 months ago
parent
commit
2116a94c18

+ 1 - 1
src/main/frontend/components/container.css

@@ -552,7 +552,7 @@
     top: 0;
     left: 0;
     right: 0;
-    background-color: or(--ls-right-sidebar-topbar-color, --lx-gray-01, --ls-secondary-background-color, #d8e1e8);
+    background-color: or(--ls-right-sidebar-topbar-color, --lx-gray-02, --ls-secondary-background-color, #d8e1e8);
     z-index: 999;
     user-select: none;
     -webkit-app-region: drag;

+ 1 - 1
src/main/frontend/components/right_sidebar.css

@@ -32,7 +32,7 @@ html[data-theme=light] {
 }
 
 .cp__right-sidebar-topbar {
-  @apply px-1 h-12 bg-transparent;
+  @apply px-1 h-12;
 
   button {
     @apply opacity-100;

+ 10 - 7
src/main/frontend/components/views.cljs

@@ -47,6 +47,12 @@
             [promesa.core :as p]
             [rum.core :as rum]))
 
+(defn- get-scroll-parent
+  [config]
+  (if (:sidebar? config)
+    (dom/sel1 ".sidebar-item-list")
+    (gdom/getElement "main-content-container")))
+
 (rum/defc header-checkbox < rum/static
   [{:keys [selected-all? selected-some? toggle-selected-all!] :as table}]
   (let [[show? set-show!] (rum/use-state false)]
@@ -1448,15 +1454,12 @@
 
 (rum/defc table-body < rum/static
   [table option rows *scroller-ref set-items-rendered!]
-  (let [[scrolling? set-scrolling!] (hooks/use-state false)
-        sidebar? (get-in option [:config :sidebar?])]
+  (let [[scrolling? set-scrolling!] (hooks/use-state false)]
     (when (seq rows)
       (ui/virtualized-list
        {:ref #(reset! *scroller-ref %)
         :increase-viewport-by {:top 300 :bottom 300}
-        :custom-scroll-parent (if sidebar?
-                                (first (dom/by-class "sidebar-item-list"))
-                                (gdom/getElement "main-content-container"))
+        :custom-scroll-parent (get-scroll-parent (:config option))
         :compute-item-key (fn [idx]
                             (let [block-id (util/nth-safe rows idx)]
                               (str "table-row-" block-id)))
@@ -1501,7 +1504,7 @@
                     (ui/virtualized-list
                      {:ref #(reset! *scroller-ref %)
                       :class "content"
-                      :custom-scroll-parent (gdom/getElement "main-content-container")
+                      :custom-scroll-parent (get-scroll-parent config)
                       :increase-viewport-by {:top 64 :bottom 64}
                       :compute-item-key (fn [idx]
                                           (let [block-id (util/nth-safe rows idx)]
@@ -1546,7 +1549,7 @@
        (ui/virtualized-grid
         {:ref #(reset! *scroller-ref %)
          :total-count (count blocks)
-         :custom-scroll-parent (gdom/getElement "main-content-container")
+         :custom-scroll-parent (get-scroll-parent config)
          :skipAnimationFrameInResizeObserver true
          :compute-item-key (fn [idx]
                              (str (:db/id view-entity) "-card-" idx))