Skip to content

Commit 927e84e

Browse files
committed
enhance(mobile): annoying keyboard behavior in the block editor modal container
1 parent 22a09ca commit 927e84e

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

src/main/frontend/util.cljc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,13 +1478,20 @@ Arg *stop: atom, reset to true to stop the loop"
14781478
(when target
14791479
(some-> target (.querySelector ".CodeMirror") (.-CodeMirror)))))
14801480

1481+
#?(:cljs
1482+
(defn get-keep-keyboard-input-el
1483+
([] (get-keep-keyboard-input-el ""))
1484+
([t]
1485+
(js/document.getElementById (str "keep-keyboard-open-input" t)))))
1486+
14811487
#?(:cljs
14821488
(defn mobile-keep-keyboard-open
14831489
([]
14841490
(mobile-keep-keyboard-open true))
14851491
([schedule?]
14861492
(when (mobile?)
1487-
(let [f #(when-let [node (gdom/getElement "app-keep-keyboard-open-input")]
1493+
(let [f #(when-let [node (or (get-keep-keyboard-input-el "in-modal")
1494+
(get-keep-keyboard-input-el))]
14881495
(.focus node))]
14891496
(if schedule? (schedule f) (f)))))))
14901497

src/main/mobile/components/app.cljs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
[mobile.state :as mobile-state]
2828
[rum.core :as rum]))
2929

30-
(rum/defc keep-keyboard-open
31-
[]
32-
[:input.absolute.top-4.left-0.w-1.h-1.opacity-0
33-
{:id "app-keep-keyboard-open-input"
34-
:auto-capitalize "off"
35-
:auto-correct "false"}])
3630

3731
(defn- sidebar-not-allowed-to-open?
3832
[]
@@ -221,7 +215,7 @@
221215
;; bottom tabs
222216
(ui-silk/app-silk-tabs)
223217

224-
(keep-keyboard-open)
218+
(ui-component/keep-keyboard-virtual-input)
225219
(ui-component/install-notifications)
226220
(ui-component/install-modals)
227221

src/main/mobile/components/modal.cljs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@
101101

102102
(rum/defc block-cp
103103
[block]
104-
[:div.app-silk-scroll-content-inner
105-
;; block page content
106-
[:div.block-modal-page-content
107-
(mobile-ui/classic-app-container-wrap
108-
(page/page-cp (db/entity [:block/uuid (:block/uuid block)])))]])
104+
[:<>
105+
(mobile-ui/keep-keyboard-virtual-input "in-modal")
106+
[:div.app-silk-scroll-content-inner
107+
;; block page content
108+
[:div.block-modal-page-content
109+
(mobile-ui/classic-app-container-wrap
110+
(page/page-cp (db/entity [:block/uuid (:block/uuid block)])))]]])
109111

110112
(rum/defc block-sheet-topbar
111113
[block {:keys [favorited? set-favorited!]}]

src/main/mobile/components/ui.cljs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
[:div#main-container.flex.flex-1
2121
[:div.w-full content]]]])
2222

23+
(rum/defc keep-keyboard-virtual-input
24+
([] (keep-keyboard-virtual-input ""))
25+
([t]
26+
[:input.absolute.top-4.left-0.w-1.h-1.opacity-0
27+
{:id (str "keep-keyboard-open-input" t)
28+
:auto-capitalize "off"
29+
:auto-correct "false"}]))
30+
2331
(rum/defc notification-clear-all
2432
[]
2533
[:div.ui__notifications-content

0 commit comments

Comments
 (0)