소스 검색

fix: dropdown menu

Tienson Qin 8 달 전
부모
커밋
1d376c0f1e
3개의 변경된 파일12개의 추가작업 그리고 15개의 파일을 삭제
  1. 2 13
      src/main/capacitor/components/app.cljs
  2. 8 2
      src/main/capacitor/components/popup.cljs
  3. 2 0
      src/main/frontend/components/views.cljs

+ 2 - 13
src/main/capacitor/components/app.cljs

@@ -114,19 +114,8 @@
                                                         (state/open-block-modal! journal)
                                                         (-> (page-handler/<create! page-name {:redirect? false})
                                                             (p/then #(state/open-block-modal! (db/get-page page-name)))))))]
-
-                                  (if (mobile-util/native-platform?)
-                                    (-> (.showDatePicker mobile-util/ui-local)
-                                        (p/then (fn [^js e] (some-> e (.-value) (apply-date!)))))
-
-                                    (ui-component/open-modal!
-                                     (fn [{:keys [close!]}]
-                                       (ion/datetime
-                                        {:presentation "date"
-                                         :onIonChange (fn [^js e]
-                                                        (let [val (.-value (.-detail e))]
-                                                          (apply-date! val)
-                                                          (close!)))}))))))}
+                                  (-> (.showDatePicker mobile-util/ui-local)
+                                      (p/then (fn [^js e] (some-> e (.-value) (apply-date!)))))))}
                    [:span.text-muted-foreground {:slot "icon-only"}
                     (ion/tabler-icon "calendar-month" {:size 24})])
 

+ 8 - 2
src/main/capacitor/components/popup.cljs

@@ -6,10 +6,16 @@
             [rum.core :as rum]))
 
 (defn popup-show!
-  [_event content-fn {:keys [id] :as opts}]
-  (if (and (keyword? id) (= "editor.commands" (namespace id)))
+  [event content-fn {:keys [id dropdown-menu?] :as opts}]
+  (cond
+    (and (keyword? id) (= "editor.commands" (namespace id)))
     ;; FIXME: Editing a block at bottom will scroll to top
     (shui-popup/show! [0 86] content-fn opts)
+
+    dropdown-menu?
+    (shui-popup/show! event content-fn opts)
+
+    :else
     (when (fn? content-fn)
       (state/set-popup! {:open? true
                          :content-fn content-fn

+ 2 - 0
src/main/frontend/components/views.cljs

@@ -181,6 +181,7 @@
                                           {:id popup-id
                                            :align "start"
                                            :as-dropdown? true
+                                           :dropdown-menu? true
                                            :on-before-hide (fn []
                                                              (reset! *last-header-action-target el)
                                                              (js/setTimeout #(reset! *last-header-action-target nil) 128))})))))}
@@ -1766,6 +1767,7 @@
                                             (shui/popup-hide!))))}
                             "Delete")])
                         {:as-dropdown? true
+                         :dropdown-menu? true
                          :align "start"
                          :content-props {:onClick shui/popup-hide!}})
                        (do