Browse Source

fix: catch tippy error

Tienson Qin 4 years ago
parent
commit
6260800ef2
1 changed files with 14 additions and 10 deletions
  1. 14 10
      src/main/frontend/ui.cljs

+ 14 - 10
src/main/frontend/ui.cljs

@@ -654,19 +654,23 @@
                     :trigger (if manual "manual" "mouseenter focus")
                     ;; See https://github.com/tvkhoa/react-tippy/issues/13
                     :popperOptions (if fixed-position?
-                                      {:modifiers {:flip {:enabled false}
-                                                   :hide {:enabled false}
-                                                   :preventOverflow {:enabled false}}}
-                                      {})
+                                     {:modifiers {:flip {:enabled false}
+                                                  :hide {:enabled false}
+                                                  :preventOverflow {:enabled false}}}
+                                     {})
                     :onShow #(reset! *mounted? true)
                     :onHide #(reset! *mounted? false)}
                    opts)
             (assoc :html (if (or open? mounted?)
-                           (when-let [html (:html opts)]
-                             (if (fn? html)
-                               (html)
-                               [:div.pr-3.py-1
-                                html]))
+                           (try
+                             (when-let [html (:html opts)]
+                              (if (fn? html)
+                                (html)
+                                [:div.pr-3.py-1
+                                 html]))
+                             (catch js/Error e
+                               (log/error :exception e)
+                               [:div]))
                            [:div {:key "tippy"} ""])))
            child)))
 
@@ -689,4 +693,4 @@
              {:id                    id
               :class                 "contents"
               :options               {:theme (when (= (state/sub :ui/theme) "dark") "dark")}
-              :on-tweet-load-success #(reset! *loading? false)})]]))
+              :on-tweet-load-success #(reset! *loading? false)})]]))