Browse Source

fix: quick add should go to editing mode asap

Tienson Qin 3 months ago
parent
commit
5dd9fc0d0a

+ 4 - 5
src/main/frontend/components/page.cljs

@@ -42,7 +42,6 @@
             [frontend.util :as util]
             [frontend.util.text :as text-util]
             [goog.object :as gobj]
-            [logseq.common.config :as common-config]
             [logseq.common.util :as common-util]
             [logseq.common.util.page-ref :as page-ref]
             [logseq.db :as ldb]
@@ -113,8 +112,7 @@
                         has-children? "opacity-0"
                         :else "opacity-50")
         config (dissoc config* :page)]
-    (when (and (or page? (util/mobile?))
-               (not= (:block/title block) common-config/quick-add-page-name))
+    (when (or page? (util/mobile?))
       [:div.ls-block.block-add-button.flex-1.flex-col.rounded-sm.cursor-text.transition-opacity.ease-in.duration-100.!py-0
        {:class opacity-class
         :parentblockid (:db/id block)
@@ -168,7 +166,7 @@
                                     (date/journal-title->int (date/today))))
                        (state/pub-event! [:journal/insert-template page-name]))))
                  state)}
-  [state block* {:keys [sidebar? whiteboard?] :as config}]
+  [state block* {:keys [sidebar? whiteboard? hide-add-button?] :as config}]
   (when-let [id (:db/id block*)]
     (let [block (db/sub-block id)
           block-id (:block/uuid block)
@@ -204,7 +202,8 @@
               blocks (if block? [block] (db/sort-by-order children block))]
           [:div.relative
            (page-blocks-inner block blocks config sidebar? whiteboard? block-id)
-           (add-button block config)])))))
+           (when-not hide-add-button?
+             (add-button block config))])))))
 
 (rum/defc today-queries < rum/reactive
   [repo today? sidebar?]

+ 2 - 1
src/main/frontend/components/quick_add.cljs

@@ -24,7 +24,8 @@
     [:div.content-inner
      {:ref *ref}
      (when scroll-container
-       (page/page-blocks-cp page {:scroll-container scroll-container}))]))
+       (page/page-blocks-cp page {:scroll-container scroll-container
+                                  :hide-add-button? true}))]))
 
 (rum/defc quick-add <
   {:will-mount (fn [state]

+ 6 - 9
src/main/mobile/components/popup.cljs

@@ -82,20 +82,17 @@
       {:presented (boolean open?)
        :onPresentedChange (fn [v?]
                             (when (false? v?)
-                              (if quick-add?
-                                (mobile-state/set-popup! nil)
-                                (js/setTimeout
-                                 #(mobile-state/set-popup! nil) 300))
-                              (state/clear-edit!)
-                              (state/pub-event! [:mobile/keyboard-will-hide])))}
+                              (js/setTimeout
+                               #(mobile-state/set-popup! nil) 300)))}
       (:modal-props opts))
      (silkhq/bottom-sheet-portal
       (silkhq/bottom-sheet-view
        {:class (str "app-silk-popup-sheet-view as-" (name (or (:type opts) "default")))
         :inertOutside false
-        :onTravelEnd (fn []
-                       (when quick-add?
-                         (js/setTimeout #(editor-handler/quick-add-open-last-block!) 50)))}
+        :onTravelStatusChange (fn [status]
+                                (when (and quick-add? (= status "entering"))
+                                  (editor-handler/quick-add-open-last-block!)))
+        :onPresentAutoFocus #js {:focus false}}
        (silkhq/bottom-sheet-backdrop
         (when quick-add?
           {:travelAnimation {:opacity (fn [data]