diff --git a/src/main/frontend/util.cljc b/src/main/frontend/util.cljc index 6a2ad19fbb..616db5b205 100644 --- a/src/main/frontend/util.cljc +++ b/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))))))) diff --git a/src/main/mobile/components/app.cljs b/src/main/mobile/components/app.cljs index 3d3323d4d6..1244280937 100644 --- a/src/main/mobile/components/app.cljs +++ b/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) diff --git a/src/main/mobile/components/modal.cljs b/src/main/mobile/components/modal.cljs index a5c25cccd2..056ab00eee 100644 --- a/src/main/mobile/components/modal.cljs +++ b/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!]}] diff --git a/src/main/mobile/components/ui.cljs b/src/main/mobile/components/ui.cljs index c33bedb209..1dc7469264 100644 --- a/src/main/mobile/components/ui.cljs +++ b/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