浏览代码

fix: popup

Tienson Qin 1 年之前
父节点
当前提交
16999a48bf

+ 4 - 3
src/main/frontend/components/block.cljs

@@ -2565,8 +2565,9 @@
                  default-hide? (or (not (and current-block-page? (not embed-self?) (state/auto-expand-block-refs?)))
                                    (= (str (:id config)) (str (:block/uuid block))))
                  *refs-count (atom nil)]
-             (p/let [count (db-async/<get-block-refs-count (state/get-current-repo) (:db/id block))]
-               (reset! *refs-count count))
+             (when-let [id (:db/id block)]
+               (p/let [count (db-async/<get-block-refs-count (state/get-current-repo) id)]
+                 (reset! *refs-count count)))
              (assoc state
                     ::hide-block-refs? (atom default-hide?)
                     ::refs-count *refs-count)))}
@@ -2642,7 +2643,7 @@
 
        (when-not (or (:block-ref? config) (:table? config))
          (when (and db-based? (seq (:block/tags block)))
-            (tags (assoc config :block/uuid (:block/uuid block)) block @*hover? edit?)))
+           (tags (assoc config :block/uuid (:block/uuid block)) block @*hover? edit?)))
 
        (when-not (or (:table? config) (:page-title? config))
          (block-refs-count block refs-count *hide-block-refs?))]

+ 4 - 1
src/main/frontend/components/icon.cljs

@@ -306,7 +306,10 @@
   (rum/local :all ::tab)
   (rum/local nil ::hover)
   {:init (fn [s]
-           (assoc s ::color (atom (storage/get :ls-icon-color-preset))))}
+           (assoc s ::color (atom (storage/get :ls-icon-color-preset))))
+   :will-unmount (fn [state]
+                   (shui/popup-hide!)
+                   state)}
   [state {:keys [on-chosen del-btn?] :as opts}]
   (let [*q (::q state)
         *result (::result state)

+ 6 - 6
src/main/frontend/components/property.cljs

@@ -114,7 +114,7 @@
                    (and *show-class-select? @*show-class-select?)
                    nil
                    add-class-property?
-                   (shui/dialog-close!)
+                   (shui/popup-hide!)
                    (and block (= type :checkbox))
                    (p/do!
                     (ui/hide-popups-until-preview-popup!)
@@ -203,19 +203,19 @@
             add-class-property?
             (p/do!
              (pv/<add-property! block (:db/ident property) "" {:class-schema? class-schema?})
-             (shui/dialog-close!))
+             (shui/popup-hide!))
 
             (= :checkbox type)
             (p/do!
              (ui/hide-popups-until-preview-popup!)
-             (shui/dialog-close!)
+             (shui/popup-hide!)
              (pv/<add-property! block (:db/ident property) false {:exit-edit? true}))
 
             (and (= :default type)
                  (not (seq (:property/closed-values property))))
             (p/do!
              (pv/<create-new-block! block property "")
-             (shui/dialog-close!))
+             (shui/popup-hide!))
 
             (or (not= :default type)
                 (and (= :default type) (seq (:property/closed-values property))))
@@ -292,9 +292,9 @@
      (mixins/hide-when-esc-or-outside
       state
       :on-hide (fn [_state _e type]
-                 (when (= type :esc)
+                 (when (contains? #{:esc} type)
+                   (shui/popup-hide!)
                    (shui/popup-hide!)
-                   (shui/dialog-close!)
                    (when-let [^js input (state/get-input)]
                      (.focus input)))))))
   {:init (fn [state]

+ 17 - 20
src/main/frontend/components/property/value.cljs

@@ -63,7 +63,7 @@
                          :logseq.property/icon
                          (select-keys icon [:type :id :color]))
                        (shui/popup-hide!)
-                       (shui/dialog-close!)))})
+                       (shui/popup-hide!)))})
      (when (and icon-value (not config/publishing?))
        [:a.fade-link.flex {:on-click (fn [_e]
                                        (p/do!
@@ -71,7 +71,7 @@
                                            (:db/id block)
                                            :logseq.property/icon)
                                          (shui/popup-hide!)
-                                         (shui/dialog-close!)))
+                                         (shui/popup-hide!)))
                            :title "Delete this icon"}
         (ui/icon "X")])]))
 
@@ -84,32 +84,30 @@
 (defn <create-new-block!
   [block property value & {:keys [edit-block?]
                            :or {edit-block? true}}]
+  (shui/popup-hide!)
   (p/let [block
           (if (and (= :default (get-in property [:block/schema :type]))
-                (not (db-property/many? property)))
+                   (not (db-property/many? property)))
             (p/let [existing-value (get block (:db/ident property))
                     existing-value? (and (some? existing-value)
-                                      (not= (:db/ident existing-value) :logseq.property/empty-placeholder))
+                                         (not= (:db/ident existing-value) :logseq.property/empty-placeholder))
                     new-block-id (when-not existing-value? (db/new-block-id))
                     _ (when-not existing-value?
                         (db-property-handler/create-property-text-block!
-                          (:db/id block)
-                          (:db/id property)
-                          value
-                          {:new-block-id new-block-id}))]
+                         (:db/id block)
+                         (:db/id property)
+                         value
+                         {:new-block-id new-block-id}))]
               (if existing-value? existing-value (db/entity [:block/uuid new-block-id])))
             (p/let [new-block-id (db/new-block-id)
                     _ (db-property-handler/create-property-text-block!
-                        (:db/id block)
-                        (:db/id property)
-                        value
-                        {:new-block-id new-block-id})]
+                       (:db/id block)
+                       (:db/id property)
+                       value
+                       {:new-block-id new-block-id})]
               (db/entity [:block/uuid new-block-id])))]
     (when edit-block?
-      (p/do!
-        (editor-handler/edit-block! block :max {:container-id :unknown-container})
-        (shui/popup-hide!)
-        (shui/dialog-close!)))
+      (editor-handler/edit-block! block :max {:container-id :unknown-container}))
     block))
 
 (defn <add-property!
@@ -132,8 +130,7 @@
           (<create-new-block! block (db/entity property-id) property-value' {:edit-block? false})
           (property-handler/set-block-property! repo (:block/uuid block) property-id property-value')))
       (when exit-edit?
-        (ui/hide-popups-until-preview-popup!)
-        (shui/dialog-close!))
+        (ui/hide-popups-until-preview-popup!))
       (when-not (or many? checkbox?)
         (when-let [input (state/get-input)]
           (.focus input)))
@@ -168,7 +165,7 @@
                       (.focus)) 16)
                  state)
    :will-unmount (fn [state]
-                   (shui/dialog-close!)
+                   (shui/popup-hide!)
                    (state/set-editor-action! nil)
                    state)}
   [state id {:keys [on-change value _del-btn? _on-delete]}]
@@ -190,7 +187,7 @@
                     (on-change (db/get-case-page journal)))
                   (shui/popup-hide! id)
                   (ui/hide-popups-until-preview-popup!)
-                  (shui/dialog-close!))))))]
+                  (shui/popup-hide!))))))]
     (ui/single-calendar
       (cond->
         {:initial-focus true