Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(right-sidebar): scroll to top if open another page on right #992

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cljs/athens/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,11 @@
:alert/js!
(fn [message]
(js/alert message)))


(reg-fx
:right-sidebar/scroll-top
(fn []
(let [right-sidebar (js/document.querySelector ".right-sidebar-content")]
(when right-sidebar
(set! (.. right-sidebar -scrollTop) 0)))))
12 changes: 9 additions & 3 deletions src/cljs/athens/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,15 @@
(compare
[(get-in new-items [k1 :index]) k2]
[(get-in new-items [k2 :index]) k1]))) inc-items)]
(cond-> {:db (assoc db :right-sidebar/items sorted-items)}
(not (:right-sidebar/open db))
(assoc :dispatch [:right-sidebar/toggle])))))
{:db (assoc db :right-sidebar/items sorted-items)
:dispatch-n [(when (not (:right-sidebar/open db)) [:right-sidebar/toggle])
[:right-sidebar/scroll-top]]})))


(reg-event-fx
:right-sidebar/scroll-top
(fn []
{:right-sidebar/scroll-top nil}))


(reg-event-fx
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/athens/views/right_sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
:z-index (:zindex-fixed ZINDICES)
:background-color (color :border-color)}
{:on-mouse-down #(swap! state assoc :dragging true)})]
[:div (use-style sidebar-content-style {:class (if open? "is-open" "is-closed")})
[:div (use-style sidebar-content-style {:class [(if open? "is-open" "is-closed") "right-sidebar-content"]})
;; [:header (use-style sidebar-section-heading-style)] ;; Waiting on additional sidebar contents
;; [:h1 "Pages and Blocks"]]
;; [button [:> FilterList]]
Expand Down