Browse Source

enhance(mobile): annoying keyboard behavior in the block editor modal container

charlie 3 weeks ago
parent
commit
9f8089c406

+ 8 - 1
src/main/frontend/util.cljc

@@ -1478,13 +1478,20 @@ Arg *stop: atom, reset to true to stop the loop"
      (when target
        (some-> target (.querySelector ".CodeMirror") (.-CodeMirror)))))
 
+#?(:cljs
+   (defn get-keep-keyboard-input-el
+     ([] (get-keep-keyboard-input-el ""))
+     ([t]
+      (js/document.getElementById (str "keep-keyboard-open-input" t)))))
+
 #?(:cljs
    (defn mobile-keep-keyboard-open
      ([]
       (mobile-keep-keyboard-open true))
      ([schedule?]
       (when (mobile?)
-        (let [f #(when-let [node (gdom/getElement "app-keep-keyboard-open-input")]
+        (let [f #(when-let [node (or (get-keep-keyboard-input-el "in-modal")
+                                  (get-keep-keyboard-input-el))]
                    (.focus node))]
           (if schedule? (schedule f) (f)))))))
 

+ 1 - 7
src/main/mobile/components/app.cljs

@@ -27,12 +27,6 @@
             [mobile.state :as mobile-state]
             [rum.core :as rum]))
 
-(rum/defc keep-keyboard-open
-  []
-  [:input.absolute.top-4.left-0.w-1.h-1.opacity-0
-   {:id "app-keep-keyboard-open-input"
-    :auto-capitalize "off"
-    :auto-correct "false"}])
 
 (defn- sidebar-not-allowed-to-open?
   []
@@ -221,7 +215,7 @@
       ;; bottom tabs
       (ui-silk/app-silk-tabs)
 
-      (keep-keyboard-open)
+      (ui-component/keep-keyboard-virtual-input)
       (ui-component/install-notifications)
       (ui-component/install-modals)
 

+ 7 - 5
src/main/mobile/components/modal.cljs

@@ -101,11 +101,13 @@
 
 (rum/defc block-cp
   [block]
-  [:div.app-silk-scroll-content-inner
-   ;; block page content
-   [:div.block-modal-page-content
-    (mobile-ui/classic-app-container-wrap
-     (page/page-cp (db/entity [:block/uuid (:block/uuid block)])))]])
+  [:<>
+   (mobile-ui/keep-keyboard-virtual-input "in-modal")
+   [:div.app-silk-scroll-content-inner
+    ;; block page content
+    [:div.block-modal-page-content
+     (mobile-ui/classic-app-container-wrap
+      (page/page-cp (db/entity [:block/uuid (:block/uuid block)])))]]])
 
 (rum/defc block-sheet-topbar
   [block {:keys [favorited? set-favorited!]}]

+ 8 - 0
src/main/mobile/components/ui.cljs

@@ -20,6 +20,14 @@
     [:div#main-container.flex.flex-1
      [:div.w-full content]]]])
 
+(rum/defc keep-keyboard-virtual-input
+  ([] (keep-keyboard-virtual-input ""))
+  ([t]
+   [:input.absolute.top-4.left-0.w-1.h-1.opacity-0
+    {:id (str "keep-keyboard-open-input" t)
+     :auto-capitalize "off"
+     :auto-correct "false"}]))
+
 (rum/defc notification-clear-all
   []
   [:div.ui__notifications-content