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

This commit is contained in:
charlie
2025-09-26 15:22:17 +08:00
parent 22a09ca776
commit 927e84e2b7
4 changed files with 24 additions and 13 deletions

View File

@@ -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)))))))

View File

@@ -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)

View File

@@ -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!]}]

View File

@@ -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