Skip to content

Commit 213ecbc

Browse files
committed
tweak: handle blurring the contact request input when keyboard is dismissed on android
1 parent 60bb12f commit 213ecbc

File tree

1 file changed

+11
-0
lines changed
  • src/status_im/contexts/profile/contact/contact_request

1 file changed

+11
-0
lines changed

src/status_im/contexts/profile/contact/contact_request/view.cljs

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require [clojure.string :as string]
33
[quo.core :as quo]
44
[react-native.core :as rn]
5+
[react-native.platform :as platform]
56
[status-im.constants :as constants]
67
[status-im.contexts.profile.contact.contact-request.style :as style]
78
[status-im.contexts.profile.utils :as profile.utils]
@@ -16,6 +17,7 @@
1617
customization-color (or customization-color constants/profile-default-color)
1718
full-name (profile.utils/displayed-name profile)
1819
profile-picture (profile.utils/photo profile)
20+
input-ref (rn/use-ref-atom nil)
1921
[message set-message] (rn/use-state "")
2022
on-message-change (rn/use-callback #(set-message %))
2123
on-message-submit (rn/use-callback (fn []
@@ -28,6 +30,14 @@
2830
:text (i18n/label
2931
:t/contact-request-was-sent)}]))
3032
[public-key message])]
33+
(rn/use-mount
34+
(fn []
35+
(let [listener (.addListener rn/keyboard
36+
"keyboardDidHide"
37+
(fn [_event]
38+
(when (and platform/android? @input-ref)
39+
(.blur ^js @input-ref))))]
40+
#(.remove ^js listener))))
3141
[:<>
3242
[quo/drawer-top
3343
{:type :context-tag
@@ -41,6 +51,7 @@
4151
[rn/view {:style style/message-input-wrapper}
4252
[quo/input
4353
{:type :text
54+
:ref #(reset! input-ref %)
4455
:multiline? true
4556
:char-limit constants/contact-request-message-max-length
4657
:max-length constants/contact-request-message-max-length

0 commit comments

Comments
 (0)