Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#17309] fix: wrong cursor position in a pre-filled composer #17329

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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