Răsfoiți Sursa

fix: wrong routes when navigating back from table row

Tienson Qin 2 săptămâni în urmă
părinte
comite
073e46d8d6

+ 1 - 1
src/main/frontend/components/views.cljs

@@ -241,7 +241,7 @@
      (state/exit-editing-and-set-selected-blocks! [cell])
      (set-focus-timeout! (js/setTimeout #(.focus cell) 100)))))
 
-(rum/defc ^:large-vars/cleanup-todo block-title
+(rum/defc ^:large-vars/cleanup-todo block-title < rum/static
   "Used on table view"
   [block* {:keys [create-new-block width row property]}]
   (let [*ref (hooks/use-ref nil)

+ 10 - 4
src/main/frontend/handler/route.cljs

@@ -20,13 +20,19 @@
             [logseq.shui.ui :as shui]
             [reitit.frontend.easy :as rfe]))
 
+(defonce *previous-route (atom nil))
 (defn redirect!
   "If `push` is truthy, previous page will be left in history."
   [{:keys [to path-params query-params push]
-    :or {push true}}]
-  (shui/popup-hide!)
-  (let [route-fn (if push rfe/push-state rfe/replace-state)]
-    (route-fn to path-params query-params))
+    :or {push true}
+    :as route}]
+  ;; avoid repeat routes
+  (when-not (= route @*previous-route)
+    (reset! *previous-route route)
+    (shui/popup-hide!)
+    (let [route-fn (if push rfe/push-state rfe/replace-state)]
+      (route-fn to path-params query-params)))
+
   ;; force return nil for usage in render phase of React
   nil)