fix: preserve the scroll position when navigating pages

This commit is contained in:
Tienson Qin
2022-05-28 02:12:42 +08:00
parent 062c2523bc
commit e649650d28
2 changed files with 5 additions and 4 deletions

View File

@@ -16,7 +16,6 @@
[{:keys [to path-params query-params push]
:or {push true}}]
(let [route-fn (if push rfe/push-state rfe/replace-state)]
(state/save-scroll-position! (util/scroll-top))
(route-fn to path-params query-params))
;; force return nil for usage in render phase of React
nil)
@@ -126,9 +125,10 @@
(update-page-label! route)
(if-let [anchor (get-in route [:query-params :anchor])]
(jump-to-anchor! anchor)
(util/scroll-to (util/app-scroll-container-node)
(state/get-saved-scroll-position)
false))))
(js/setTimeout #(util/scroll-to (util/app-scroll-container-node)
(state/get-saved-scroll-position)
true)
100))))
(defn go-to-search!
[search-mode]