Skip to content

Commit

Permalink
fix(ui): incorrect scrollable container for the blocks list within th…
Browse files Browse the repository at this point in the history
…e right sidebar
  • Loading branch information
xyhp915 committed Nov 8, 2024
1 parent 141bf4c commit 3ac14d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 8 additions & 9 deletions src/main/frontend/components/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand All @@ -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)]
Expand Down Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion src/main/frontend/components/reference.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/main/frontend/components/right_sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
[]
Expand Down

0 comments on commit 3ac14d7

Please sign in to comment.