Skip to content

Commit 97e7d46

Browse files
committed
fix: reply cancel input blur and smooth reply focus
1 parent 6940ccd commit 97e7d46

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

src/status_im2/contexts/chat/composer/effects.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@
159159
(when reply
160160
(reanimated/animate container-opacity 1))
161161
(when (and reply @input-ref @messages-list-on-layout-finished?)
162-
(js/setTimeout #(.focus ^js @input-ref) 250))))
163-
[(:message-id reply)])
162+
(js/setTimeout #(.focus ^js @input-ref) 600)))
163+
[(:message-id reply)]))
164164

165165
(defn update-input-mention
166166
[{:keys [input-ref]}

src/status_im2/contexts/chat/composer/reply/view.cljs

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[status-im2.constants :as constant]
1010
[status-im2.contexts.chat.composer.constants :as constants]
1111
[status-im2.contexts.chat.composer.reply.style :as style]
12+
[status-im2.contexts.chat.composer.utils :as utils]
1213
[utils.ens.stateofus :as stateofus]
1314
[utils.i18n :as i18n]
1415
[utils.re-frame :as rf]))
@@ -85,7 +86,7 @@
8586
(defn quoted-message
8687
[{:keys [from content-type contentType parsed-text content deleted? deleted-for-me?
8788
album-images-count]}
88-
in-chat-input? pin? recording-audio?]
89+
in-chat-input? pin? recording-audio? input-ref]
8990
(let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity from])
9091
current-public-key (rf/sub [:multiaccount/public-key])
9192
content-type (or content-type contentType)
@@ -136,7 +137,7 @@
136137
{:icon-only? true
137138
:size 24
138139
:accessibility-label :reply-cancel-button
139-
:on-press #(rf/dispatch [:chat.ui/cancel-message-reply])
140+
:on-press #(utils/cancel-reply-message input-ref)
140141
:type :outline}
141142
:i/close])
142143
(when (and in-chat-input? recording-audio?)
@@ -148,13 +149,13 @@
148149
:style style/gradient}])]))
149150

150151
(defn- f-view
151-
[recording?]
152+
[recording? input-ref]
152153
(let [reply (rf/sub [:chats/reply-message])
153154
height (reanimated/use-shared-value (if reply constants/reply-container-height 0))]
154155
(rn/use-effect #(reanimated/animate height (if reply constants/reply-container-height 0)) [reply])
155156
[reanimated/view {:style (reanimated/apply-animations-to-style {:height height} {})}
156-
(when reply [quoted-message reply true false recording?])]))
157+
(when reply [quoted-message reply true false recording? input-ref])]))
157158

158159
(defn view
159-
[{:keys [recording?]}]
160-
[:f> f-view @recording?])
160+
[{:keys [recording?]} input-ref]
161+
[:f> f-view @recording? input-ref])

src/status_im2/contexts/chat/composer/utils.cljs

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
(rf/dispatch [:chat.ui/set-input-focused false])
106106
(.blur ^js @input-ref)))
107107

108+
(defn cancel-reply-message
109+
[input-ref]
110+
(js/setTimeout #(blur-input input-ref) 100)
111+
(rf/dispatch [:chat.ui/set-input-content-height constants/input-height])
112+
(rf/dispatch [:chat.ui/cancel-message-reply]))
113+
108114
(defn cancel-edit-message
109115
[text-value input-ref]
110116
(reset! text-value "")

src/status_im2/contexts/chat/composer/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
[sub-view/bar]
9999
(when chat-screen-loaded?
100100
[:<>
101-
[reply/view state]
101+
[reply/view state (:input-ref props)]
102102
[edit/view
103103
{:text-value (:text-value state)
104104
:input-ref (:input-ref props)}]])

0 commit comments

Comments
 (0)