Skip to content

Commit

Permalink
[#17309] fix: wrong cursor position in a pre-filled composer (#17329)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri authored Sep 20, 2023
1 parent 5bb954f commit 41282a9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/status_im2/contexts/chat/composer/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
(rn/use-effect
(fn []
(maximized-effect state animations dimensions chat-input)
(reenter-screen-effect state dimensions chat-input)
(layout-effect state)
(kb-default-height-effect state)
(background-effect state animations dimensions chat-input)
Expand All @@ -98,20 +97,27 @@
(empty-effect state animations subscriptions)
(kb/add-kb-listeners props state animations dimensions)
#(component-will-unmount props))
[max-height]))
[max-height])
(rn/use-effect
(fn []
(reenter-screen-effect state dimensions subscriptions))
[max-height subscriptions]))

(defn use-edit
[{:keys [input-ref]}
{:keys [text-value saved-cursor-position]}
{:keys [edit]}]
(rn/use-effect
(fn []
(let [edit-text (get-in edit [:content :text])]
(let [edit-text (get-in edit [:content :text])
text-value-count (count @text-value)]
(when (and edit @input-ref)
(.focus ^js @input-ref)
(.setNativeProps ^js @input-ref (clj->js {:text edit-text}))
(reset! text-value edit-text)
(reset! saved-cursor-position (count edit-text)))))
(reset! saved-cursor-position (if (zero? text-value-count)
(count edit-text)
text-value-count)))))
[(:message-id edit)]))

(defn use-reply
Expand Down

0 comments on commit 41282a9

Please sign in to comment.